Git provides multiple commands for listing branches. All commands use the function of git branch
, which will provide a list of a certain branches, depending on which options are put on the command line. Git will if possible, indicate the currently selected branch with a star next to it.
Goal | Command |
---|---|
List local branches | git branch |
List local branches verbose | git branch -v |
List remote and local branches | git branch -a OR git branch --all |
List remote and local branches (verbose) | git branch -av |
List remote branches | git branch -r |
List remote branches with latest commit | git branch -rv |
List merged branches | git branch --merged |
List unmerged branches | git branch --no-merged |
List branches containing commit | git branch --contains [<commit>] |
Notes:
v
to -v
e.g. $ git branch -avv
or $ git branch -vv
will print the name of the upstream branch as well.