some basic commands for branches. you can read the official page for more details
you wanna develope a feature, fix a bug, test some stuff … you need a branch !
git checkout -b feature1
if you have a central repo, push the feature upstream (so others can checkout as well)
git push --set-upstream origin feature1
you may have multiple branches, list them all. and update pager so list will not open in VIM !
git config --global pager.branch false git branch git branch -a
from master to feature1 and back to master
git checkout master git checkout feature1 git checkout master
if your’re fine with your code, you merge your branch into master
git checkout master git merge feature1
git delete branch
finally, delete the branch and process with on the master
git branch -d feature1
git switch & restore
new commands in git v2.23
git switch -c new_branch
and switch back to master
git switch master
Restore lastest version
git restore -- test.txt
or even from another branch
git checkout new_branch -- test.txt
Happy Git !