git show printing unwanted tag info

116 views Asked by At

When using this command:

$ git show -s --pretty=format:%H --all

it prints this:

41b253549d86db3432743c1c8a9f75511779073c
83cfbe4b5a128ab06733fdde24f67171a1cf945c

20c18bee751e681856ee4587bb513400b472f941
ba73e741f3ccf7b719a67436cf8b953a1bdeeb89

tag 1.0
Tagger: <snip>


129cba44e34066bfee7ad19a278ead94c2edece9
tag 1.0.1
Tagger: <snip>


6fcdc763265454e602b746e4d81942a1f0597f2e
tag 1.0.2
Tagger: <snip>


36e56a8bc0d568661fa61cdb0a4e4c69c4c30efb
tag 1.0beta1
Tagger: <snip>

I only want commit hashes to be printed, not tag names and taggers. What should I do to fix this?

3

There are 3 answers

1
Michał Politowski On BEST ANSWER

I'm not sure if you want to list the tagged commits but omit the tag info or do not want the tagged commits included at all.

If it is the first case then git rev-list --all --no-walk should do what you want.

For the second case git rev-list --branches --no-walk, or even git show -s --pretty=format:%H --branches will do.

0
amorfis On

If you know your first commit hash, let's assume it's e562b3, you can do this:

git show -s --pretty=format:%H e562b3..HEAD
0
Brian Phillips On

Did you try using git log --pretty=format:%H --all instead of using git show?

You don't really say what your goal is but you might even want to just use git rev-list --all.

(I can't reproduce the behavior you're seeing even on a repo that has tags but perhaps using git log or git rev-list will do the trick)