Git command to display HEAD commit id?

前端 未结 9 1721
轮回少年
轮回少年 2020-12-22 15:27

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/head         


        
相关标签:
9条回答
  • 2020-12-22 15:56

    Play with Bash:

    git show HEAD | sed -n 1p | cut -d " " -f 2
    
    0 讨论(0)
  • 2020-12-22 15:57
    git log -1
    

    for only commit id

    git log | head -n 1 
    
    0 讨论(0)
  • 2020-12-22 15:58

    Use the command:

    git rev-parse HEAD
    

    For the short version:

    git rev-parse --short HEAD
    
    0 讨论(0)
提交回复
热议问题