Branches¶
Change the commit a branch points to¶
git branch -f <branch> <commit>
Useful if you accidentally commit to your local main
!
Rename a branch¶
git branch -m <name>
or
git branch -m <old> <new>
Upstream Branches¶
Start tracking a remote branch
$ git branch --set-upstream origin/branchname
Stop tracking the upstream branch
$ git branch --unset-upstream
Verbose Info¶
Pass a few -v
flags to git branch
to get more useful information!
$ git branch -vv
develop c46fa42 [origin/develop] Add exciting new integration
* new-feature a1b2c3f WIP
main 0cd3fd3 [origin/main] Merge pull request #123
hotfix 9a2eff5 [origin/hotfix: ahead 3, behind 2] Fix infinite loop