How can I list git branches showing and sorting by their last commits' dates?
I've found this:
for k in `git branch | sed s/^..//`; do
echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" "$k"`\\t"$k";
done | sort -r
I'd expect plain git to have this feature. Does it?
I also found git show-branch --date-order
but the output is something different.
Use git branch --sort=-committerdate to display a list of all local branches and sort them based on the date of their last commit. Use arrow keys to navigate, press Q to exit.
In order to compare two branches easily, you have to use the “git diff” command and provide the branch names separated by dots. Using this command, Git will compare the tip of both branches (also called the HEAD) and display a “diff” recap that you can use to see modifications.
Command #1: git branch -r This Git command will show you remote branches.
This appears to be a built-in way to achieve that (v1.7.4):
git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'
I've enjoyed the @Will Sheppard solution to put some colors.
git for-each-ref --sort=committerdate refs/heads/ --format='%(color: red)%(committerdate:short) %(color: cyan)%(refname:short)'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With