Search code examples
bashgitgrepgit-tag

git reflog missing data when piping


With

git reflog

output log look like this

8b388bc (HEAD -> master) HEAD@{0}: commit (amend): tempppp22222
7c33c70 (tag: v2.0) HEAD@{1}: commit: tempppp
76702b2 (origin/master, origin/HEAD) HEAD@{2}: reset: moving to HEAD^
fc1ea9d HEAD@{3}: commit (amend): temp2
0bc8223 (tag: v1.0) HEAD@{4}: reset: moving to 0bc8223

but when I try

git reflog | grep "HEAD@{1}"

the output look like this

7c33c70 HEAD@{1}: commit: tempppp

Can someone tell me why the tag name is missing?


Solution

  • git reflog --help:

    OPTIONS
    Options for show
    git reflog show accepts any of the options accepted by git log.

    git log --help:

    OPTIONS
    --no-decorate, --decorate[=short|full|auto|no]
    Print out the ref names of any commits that are shown. If short is specified, the ref name prefixes refs/heads/, refs/tags/ and refs/remotes/ will not be printed. If full is specified, the full ref name (including prefix) will be printed. If auto is specified, then if the output is going to a terminal, the ref names are shown as if short were given, otherwise no ref names are shown. The option --decorate is short-hand for --decorate=short. Default to configuration value of log.decorate if configured, otherwise, auto.

    TL;DR: use --decorate