Is there a single Git command to get the current tag, branch and commit?

Posted by Koraktor on Stack Overflow See other posts from Stack Overflow or by Koraktor
Published on 2010-05-19T08:00:40Z Indexed on 2010/05/20 0:50 UTC
Read the original article Hit count: 217

Filed under:
|

I'm currently using a collection of three commands to get the current tag, branch and the date and SHA1 of the most recent commit.

git describe --always --tag
git log -1 --format="%H%n%aD"
git rev-parse --abbrev-ref HEAD

Which will output something like:

1.2.3-gdeadbeef
deadbeef3b8d90071c24f51ac8f26ce97a72727b
Wed, 19 May 2010 09:12:34 +0200
master

To be honest, I'm totally fine with this. But I'm using these commands from Maven and anyone who'd used Maven before, knows how much things like external commands bloat the POM. I just want to slim down my pom.xml and maybe reduce execution time a bit.

© Stack Overflow or respective owner

Related posts about git

Related posts about command-line