git recent branches help
In most cases, we follow the branching model for any feature or bug fixes for application source.
Like create a branch from master or development and make the changes which are needed and generate a pull request and if your team is validating your changes merge the branch to master.
And if you follow this pattern then you might end with a lot of local git branches if you haven’t set up any alarm or job to clear you local branches after a certain time (30 days)
So we have a lot of local git branches(which I certainly have) and I want to see what are my recent work branches.
I will just type below command in terminal to see that
# to see all local branches
git branch -l
# to see all remote-tracking branches
git branch -r
# to see all remote branches
git branch -a
# to see all local and remote branches
git branch -al
But this doesn’t show us branches chronologically. How we can do that?
Hola! git has it all ☺️
# show most recet commits based on committerdate
git for-each-ref --sort=-committerdate refs/heads
# show most recet commits first reverse chronological
# (DESC order by commiterdate)
git branch --sort=-committerdate
# show most recet commits last chronological
# (ASC order by commiterdate)
git branch --sort=committerdate
# show commits with commit date
git for-each-ref --sort='-committerdate' \
--format='%(refname)%09%(committerdate)' \
refs/heads | sed -e 's-refs/heads/--'