This file provides commands to display a list of Git branches ordered by the 20 most recent commits, both locally and including remote branches. These commands are helpful for developers to easily track recent activity in the repository.
To view a list of local Git branches sorted by commit date, use the following command:
git for-each-ref --count=20 --sort=-committerdate refs/heads --format='%(authordate:short) %(color:red)%(objectname:short) %(color:yellow)%(refname:short)%(color:reset) (%(color:green)%(committerdate:relative)%(color:reset))'
This command retrieves the 20 most recent branches and displays them along with their commit dates, commit hashes, and branch names, sorted in descending order by default.
To sort the branches in ascending order, simply remove the -
sign before committerdate
in the command.
To display both local and remote Git branches sorted by commit date, execute the following command:
git for-each-ref --count=20 --sort=-committerdate refs/heads refs/remotes --format="%(authordate:short) %(color:red)%(objectname:short) %(color:yellow)%(refname:short)%(color:reset) (%(color:green)%(committerdate:relative)%(color:reset)) %(authorname)"
This command retrieves the 20 most recent branches from both local and remote repositories, providing information on commit dates, commit hashes, branch names, and author names.
Feel free to utilize these commands to stay up-to-date with the latest developments in your Git repository!