Home > Net >  git reflog - branch level summary
git reflog - branch level summary

Time:12-15

git reflog shows how HEAD moved between commits.

Is there a way to show only branches?

(i.e. show only one line per branch visit)

CodePudding user response:

One way to list previous HEAD positions is to use the [HEAD]@{-<n>} construct, where n means nth last position of HEAD, branch-wise. But as eftshift0 already mentioned in comments, this is not set in stone information, since branches are moving. Can be useful in some contexts, though, to understand what happened.

Here, an alias to illustrate my point :

$ git config --global alias.last '!f() { for i in $(seq 1 $1); do git name-rev --name-only --exclude=refs/tags/\* @{-$i}; done; }; f'

$ git last 5
master
dev
feature/abc
master
feature/abc

where n is the number of previous positions to fetch.

CodePudding user response:

Close enough (includes also tags):

 git reflog -5 --pretty='%d' | uniq
  • Related