Git Listing branches


Example

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.

GoalCommand
List local branchesgit branch
List local branches verbosegit branch -v
List remote and local branchesgit branch -a OR git branch --all
List remote and local branches (verbose)git branch -av
List remote branchesgit branch -r
List remote branches with latest commitgit branch -rv
List merged branchesgit branch --merged
List unmerged branchesgit branch --no-merged
List branches containing commitgit branch --contains [<commit>]

Notes:

  • Adding an additional v to -v e.g. $ git branch -avv or $ git branch -vv will print the name of the upstream branch as well.
  • Branches shown in red color are remote branches