InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Git tutorials

  • Github for beginners
  • Undo last commit
  • List git branches
  • Git checkout remote branch
  • Diff two branches
  • Show log of one user's commits
  • View diff for a given commit id
  • Setup password less git push for github
  • Git - Check if a hash is valid
  • Git - display specific length commit hash
  • Git - rename local branch
  • Git create branch
  • Git delete branch
  • Git detached head
  • Git display info of last commit (HEAD) in one line
  • Git display local HEAD location
  • Git log with file names
  • Git show details of a commit hash
 
  • Home
  • > Tutorials
  • > Git

How to list git branches

By admin on Nov 14, 2015

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

Suggested posts:

  1. Ubuntu – reload iptables rules during boot
  2. How to disable sleep during android usb debugging
  3. Git create branch
  4. Perl command line – replace multi line comments
  5. Linux find – ignore case in name
  6. Git log with file names
  7. Linux screen – quick start guide
  8. Git display local HEAD location
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Git, Mac, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress