获取简短的git版本哈希 [英] Get the short git version hash
本文介绍了获取简短的git版本哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从 git
?
HEAD
的短版本散列是否有更简洁的方法? b $ b
我希望看到和我一样的输出
|头-n 1 | sed -e's / ^ commit //'| head -c 8
UPDATE :我最初使用它来生成一个版本字符串,但这更好:
git describe --tags
它会输出像 0.1.12
提交)或 0.1.11-5-g0c85fbc
(5在提交标签后提交)。 / b>试试这个:
git rev-parse --short HEAD
命令 git rev-parse
可以做很多不同的事情,所以你需要通过文档非常小心地发现,虽然。
Is there a cleaner way to get the short version hash of HEAD
from git
?
I want to see the same output as I get from
git log -n 1 | head -n 1 | sed -e 's/^commit //' | head -c 8
UPDATE: I originally used this to generate a version string, but this is even better:
git describe --tags
It will output strings like 0.1.12
(tagged commit) or 0.1.11-5-g0c85fbc
(5 commits after the tag).
解决方案
Try this:
git rev-parse --short HEAD
The command git rev-parse
can do a remarkable number of different things, so you'd need to go through the documentation very carefully to spot that though.
这篇关于获取简短的git版本哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文