Git命令显示头提交ID? [英] Git command to display HEAD commit id?

查看:124
本文介绍了Git命令显示头提交ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这是我手工做的事:

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

但我需要一个脚本,可以将某些命令的输出一个文本文件,使得文本文件包含HEAD的提交ID(没有更多或更少,而不仅仅是参考)。任何人都可以帮忙吗?

解决方案

使用命令:

  git rev-parse HEAD 

对于短版本:

  git rev-parse --short HEAD 


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?

解决方案

Use the command:

git rev-parse HEAD

For the short version:

git rev-parse --short HEAD

这篇关于Git命令显示头提交ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆