I want list use git reflog format
, and show it as sorted by date with (--date=relative
) flag.
git reflog --format='%C(auto)%h %<|(17)%gd %C(blue)%cr%C(reset) %gs'
has following output:
$ git reflog --format='%C(auto)%h %<|(17)%gd %C(blue)%cr%C(reset) %gs'
cec94e5c HEAD@{0} 12 hours ago checkout: moving from 4ad171a16415754987475d38c0864278982f9d12 to dev
4ad171a1 HEAD@{1} 3 weeks ago checkout: moving from 9e0b5961ff88310b4ab41d90f34914f7b951ec69 to 4ad171a1
9e0b5961 HEAD@{2} 3 days ago checkout: moving from dev to 9e0b5961
cec94e5c HEAD@{3} 12 hours ago checkout: moving from 4ad171a16415754987475d38c0864278982f9d12 to dev
4ad171a1 HEAD@{4} 3 weeks ago checkout: moving from dev to 4ad171a1
cec94e5c HEAD@{5} 12 hours ago reset: moving to HEAD
cec94e5c HEAD@{6} 12 hours ago pull --rebase --autostash (finish): returning to refs/heads/dev
git reflog --date=relative
has following output:
$ git reflog --date=relative
cec94e5c (HEAD -> dev, origin/dev) HEAD@{3 seconds ago}: checkout: moving from 4ad171a16415754987475d38c0864278982f9d12 to dev
4ad171a1 HEAD@{11 hours ago}: checkout: moving from 9e0b5961ff88310b4ab41d90f34914f7b951ec69 to 4ad171a1
9e0b5961 HEAD@{11 hours ago}: checkout: moving from dev to 9e0b5961
cec94e5c (HEAD -> dev, origin/dev) HEAD@{11 hours ago}: checkout: moving from 4ad171a16415754987475d38c0864278982f9d12 to dev
4ad171a1 HEAD@{11 hours ago}: checkout: moving from dev to 4ad171a1
cec94e5c (HEAD -> dev, origin/dev) HEAD@{11 hours ago}: reset: moving to HEAD
cec94e5c (HEAD -> dev, origin/dev) HEAD@{11 hours ago}: pull --rebase --autostash (finish): returning to refs/heads/dev
Here when we use git reflog --date=relative
could we also show the HEAD@{<Number>}
corresponding to each item that matches to git commit hash.
Related: Is there a way to cause git-reflog to show a date alongside each entry?