Git command to display HEAD commit id?

Posted by Andrew Arnott on Stack Overflow See other posts from Stack Overflow or by Andrew Arnott
Published on 2009-12-28T04:30:57Z Indexed on 2010/04/01 2:53 UTC
Read the original article Hit count: 315

Filed under:
|

What command can I use to print out the commit id of HEAD?

This is what I'm doing by hand:

$ cat .git/HEAD
ref: refs/heads/v3.3
$ cat .git/refs/heads/v3.3
6050732e725c68b83c35c873ff8808dff1c406e1

But I need a script that can reliably pipe the output of some command to a text file such that the text file contains exactly the commit id of HEAD (nothing more or less, and not just a ref). Can anyone help?

© Stack Overflow or respective owner

Related posts about version-control

Related posts about git