List remote Git branches With the last commit date, commit user, Sort by most recent commit date

Find the last committed Date and Time in the current local branch :
$ git log -1 --format=%cd
>>>Sun Jun 14 05:03:27 2020 +0530


Find the last committed dates in current checkout local branches :
ASC
$ for k in `git branch | perl -pe s/^..//`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r
>>>2020-06-14 05:03:27 +0530 3 weeks ago branch2
>>>2020-05-03 10:10:41 +0000 9 weeks ago master

DESC
$ 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
>>>2020-05-03 10:10:41 +0000 9 weeks ago master
>>>2020-06-14 05:03:27 +0530 3 weeks ago branch2


Using git branch -r, you can similarly show remote branches :
$ for k in `git branch -r | perl -pe 's/^..(.*?)( ->.*)?$/\1/'`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r
>>>>
2020-06-14 07:17:02 +0000 3 weeks ago branch3
2020-06-14 05:03:27 +0530 3 weeks ago branch1
2020-06-12 04:27:18 +0530 4 weeks ago branch2
2020-06-11 22:23:58 +0530 4 weeks ago branch6
2020-05-29 04:31:13 +0000 6 weeks ago branch8


If you are also interested in the last author on the branch, and if you have the "column" tool available, you can use:
$ git for-each-ref --sort='-committerdate:iso8601' --format='%(committerdate:relative)|%(refname:short)|%(committername)' refs/remotes/ | column -s '|' -t 
>>>>
3 weeks ago   branch3                  Jayakody
3 weeks ago   branch1                  Sahan
4 weeks ago   branch2                  dilshan
4 weeks ago   branch6                  akna
5 weeks ago   branch8                  Sahan


For More

Comments

Popular posts from this blog

Install Ubuntu (20.04.1 LTS) with Windows (Dual boot mode)

How to Mirror Android Screen to Ubuntu(GNU/Linux) Desktop With Scrcpy

Grub Not Showing For Windows