It is related to Making git show to show information in a machine parseable format but I am getting tired of the fact that I now have to do a lot of parsing to get the commit hash.
Can someone give me a command that will print the commit hash (and only the commit hash) tag for a given git tag? I was hoping
git show mylabel --pretty=format:"%H" --quiet Would just print me my commit # but it says
tag mylabel Tagger: user <[email protected]> Some comment 446a52cb4aff90d0626b8232aba8c40235c16245 I was expecting one line of output with just the commit line but I now have to parse for the last line?
git log --color=neverI get a full log of commits with branches and tags listed next to the commit hash, but then, if I want to filter the first lines to view all hashes next to their tag and branch names, as you do, and I pipe it through grep, suddenlygit log --color=never | grep '^commit'simplifies it's output and the commit lines no longer have the tag and branch names included. The same happens if I just redirect to a file. The output is missing the tag name embellishments.man git log. The "embellishments" are officially known as "decorations" and are implicitly provided to terminals but are dropped when piping. They can be forced with the addition of--decorate. Sogit log --decorate --color=never | grep '^commit.*tag'lives a list of all commit hashes that are also tagged.