How to list git branches

These are various command to list git local and remote branches. Note that local branches may be different from remote branches.

List git local branches

$ git branch

List git remote branches

$ git branch -r

List git all (local and remote) branches

$ git branch -a

List all local branches sorted by last commit date

Here is command to list all local branches sorted by last commit date. It also displays last commit author and date.

$ git for-each-ref --sort=-committerdate --format='%(refname) | %(committerdate) | %(authorname)' refs/heads/

List all remote branches sorted by last commit date

Here is command to list all remote branches sorted by last commit date. It also displays last commit author and date.

$ git for-each-ref --sort=-committerdate --format='%(refname) | %(committerdate) | %(authorname)' refs/remotes/origin

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments