git 查看提交哈希值_如何在git中获取最新提交的哈希?

git 查看提交哈希值

I am looking for a better method for getting the latest commit’s hash in git.

我正在寻找一种更好的方法来获取git中最新commit的哈希值。

I know git log -1 can show the info of the latest commit and from the info of the latest commit I can use grep and other tools to get the hash.

我知道git log -1可以显示最新提交的信息,根据最新提交的信息,我可以使用grep和其他工具来获取哈希。

Is there better method supported from git?

git支持更好的方法吗?

Note: a better method is introduced in this QA.

注意: 此质量检查中引入了更好的方法。

You can use the --format option of git log:

您可以使用git log--format选项:

git log -n1 --format=format:"%H"

Here, “%H” means “commit hash”.

在此,“%H”表示“提交哈希”。

For explanation and other options of the format string, please check git log manual.

有关格式字符串的说明和其他选项,请检查git log手册

Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。

翻译自: https://www.systutorials.com/how-to-get-the-latest-commits-hash-in-git/

git 查看提交哈希值

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值