I have written an alias to output the N last checked out branches
git config --global alias.last '!f() { for i in $(seq 1 $1); do git name-rev --name-only @{-$i}; done; }; f'
...and it works almost fine.
$ git last 4
some-branch
some-other-branch
tags/some-tag^0
yet-another-branch
Problem is, of course, line 3 of output, when a ref (in this case @{-3}) points to a commit referenced by both a tag and a branch. It outputs the tag by default while I'd prefer the branch name (when there's one).
I tried a few things, namely using ^{} to dereference the tag, but to no avail.
Do you, by any chance, see what I'm missing, and know how to dereference the tag here?
Update after accepted answer : working version of the alias
git config --global alias.last '!f() { for i in $(seq 1 $1); do git name-rev --name-only --exclude=refs/tags/\* @{-$i}; done; }; f'