Find the recent git branch

Find all the commits to the git repo

You have a git repo but don’t have any idea what the most recent git branch. You can find it from the git repo.
In my case i have access to the git repo in my linux machine as follows

/home/git/my_lib.git

Once you are in the folder issue the following command

git for-each-ref --sort=-committerdate refs/heads

the output will look like this

093ae543bf40e3394c95b75074d1c87f1ccd248a commit	refs/heads/br_11_20_2013
10d8be135e15b40cdf62dbf212c4768c2b4b2cab commit	refs/heads/master
e9e0cb4ac232207c970d660e08ca7214db21efd8 commit	refs/heads/br_5_17_2013
3c123ae255e9b4ec9850a889de9f3dfbb6766c1f commit	refs/heads/br_4_24_2013
ea16d0a376c125aa1a47647a562ec74212801923 commit	refs/heads/br_11_24_2012
427ad84f7f9dbef690bd875550045f02b6344736 commit	refs/heads/br_10_25_2012
35aba3460091b7d4bad8a6ca102061e21d2cb404 commit	refs/heads/br_8_19_2012
15c2db0c9289db380127d54c9ad341ece86532c7 commit	refs/heads/br_5_18_2012

Now based on the output, the most recent branch is br_11_20_2013

Posted in git

Comments are closed.