[英]simplest way to get the SHA of an arbitrary git object?
I want a git command that simply outputs the SHA of an arbitrary object (commit, tree, blob, whatever). 我想要一个git命令,该命令只输出任意对象(commit,tree,blob等)的SHA。 Basically:
基本上:
$ git sha HEAD
7b78f727c91edc7726f3c31113bc7b1509fea163
$ git sha master^:CHANGELOG
0dcc5f003ed89c30a8d0376a29d546c20449fd90
...and so forth. ...等等。 This should be the simplest thing in the world, but I can't figure out a good way of doing it.
这应该是世界上最简单的事情,但是我想不出一个好方法。 I don't mind using an alias to a complex, option-laden git command, but it seems like I must just be missing a really simple dereference command that git must surely use under the hood all the time.
我不介意为复杂的,带有选项的git命令使用别名,但是似乎我必须丢失git必须始终在幕后使用的一个非常简单的取消引用命令。
For the purposes you have given, your git sha
is actually git rev-parse
. 对于您给出的目的,您的
git sha
实际上是git rev-parse
。
% git rev-parse HEAD
47753f420d6ec7d84f8705e9acb67693745b4a8b
% git rev-parse origin/pu^:Documentation/RelNotes-1.7.1.txt
9d89fedb36b4d6fa7c8a6a8487cc47b4ca542e3a
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.