如何“取消引用”一个字符串到 git sha1 哈希值?

发布于 2024-12-21 11:34:51 字数 248 浏览 5 评论 0原文

如何获取 HEADHEAD^^^HEAD~8 等引用的 sha1 哈希值?

我知道我可以破解 git show 来得到我想要的东西,但它会吐出一堆我不想要的其他东西。例如。

git show HEAD^^ --pretty=format:%H | head -n1

什么是更简单的命令,更直接地达到我想要实现的目的?

How do you get the sha1 hash for references like HEAD, HEAD^^^, HEAD~8?

I know I can hack up git show to get what I want, but it spits out a bunch of other stuff I don't want. Eg.

git show HEAD^^ --pretty=format:%H | head -n1

What is a simpler command that is more direct to the intent of what I am trying to achieve?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一绘本一梦想 2024-12-28 11:34:51

您想使用:

git rev-parse HEAD

You want to use:

git rev-parse HEAD
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文