Git

Last Updated: 10/3/2023

Collaboration Workflow

User 1

Create branch on Github

  • You can create branch directly on Github
  • Go to github > branch dropdown > enter branch name feature/change-password > press enter

Get remote tracking branch

git fetch

Create branch and map to remote tracking branch

  • create a private branch in our local repository that maps to the remote tracking branch.
git branch
git branch -r
git switch -C feature/change-password origin/feature/change-password

User 2

Clone new branch

git clone branch-url

Create branch and map to remote tracking branch

  • create a private branch in our local repository that maps to the remote tracking branch.
git branch
git switch -C feature/change-password origin/feature/change-password

Add new commit

echo password > file1.txt
git commit -am "Update file1.txt"
git push

User 1

Get latest and merge

git pull
git log --oneline --all --graph
git switch master
git merge feature/change-password
git push

Remove remote tracking branch

git push -d origin feature/change-password
git branch -d feature/change-password

User 2

git switch master
git pull
git branch -d feature/change-password

Remove remote tracking branch that are not in remote

git remote prune origin