1. Create your own branch to work on your dedicated task (only one branch for multiple people working on the same task)
git branch <your_branch_name>
git checkout <you_branch_name>
To see the status of your branch at any time, you can use :
git status
git commit -m "<description of your commit>"
4. Creating the branch on the remote repository and setting your local repository to track this branch
git push -u origin <you_branch_name>
git push
git pull
When you decide that your task is finished and your code as been tested, you may want to add your modifications to the main branch. However, you have to follow strictly the following steps to avoid creating any conflict on the main branch.
git checkout main
git pull
git checkout <your_branch_name>
This step is already described in the first part of this document.
git merge main
- Resolve the conflicts.
- Commit the changes made to resolve conflicts on your branch.
git checkout main
git pull
- If the
main
branch has changed, repeat from step 2.
git checkout <your_branch_name>
git push
Two methods are available for this last step, one using the website Github and anothe rusing the CLI. Choose the one that suits you the most.
a. Go to the website git repository on Github.
b. Open the "Pull requests" tab
c. Click on "Create pull request"
d. Choose "main" as base and <you_branch_name> as compare
e. Proceed to the opening of the pull request
f. Notify your teammates that they have to review your pull request and accept it if they are ok with it OR accept yourself the request if you know what you are doing and that everyone is ok with it
git checkout main
git merge <your_branch_name>
git push
I hope that it helped you mates ;)