如何在git中显示关于单个提交的元信息(How to display metadata about single commit in git?)

编程入门 行业动态 更新时间:2024-10-27 07:31:40
如何在git中显示关于单个提交的元信息(How to display metadata about single commit in git?)

我想从git仓库解析metainformations。 我想为提交获取单个信息,例如

git log --pretty=format:%an HEAD^..HEAD

问题是,这不适用于存储库中的第一次提交。

git show --pretty=format:%an HEAD^..HEAD

也接近我想要的,除了我不感兴趣解析实际差异。

任何想法如何使git日志工作的第一次提交或如何禁用显示提交内容的git显示?

或者,有没有更好的方法来检索给定提交的元数据?

I'd like to parse meta information from git repository. I'd like to fetch a single information for a commit, as in

git log --pretty=format:%an HEAD^..HEAD

Problem is, this is not working for the first commit in repository.

git show --pretty=format:%an HEAD^..HEAD

is also close to what I want, except I'm not interested in parsing actual diff.

Any idea how to make git log work for the first commit or how to disable git show from showing commit content?

Or, is there any better way how to retrieve metadata about given commit?

最满意答案

提供安静选项以显示抑制差异。

git show --quiet HEAD

所以对于你的例子,作者姓名:

git show --quiet --pretty=format:%an

Supply the quiet option to show to suppress the diff.

git show --quiet HEAD

So for your example, author name:

git show --quiet --pretty=format:%an

更多推荐

本文发布于:2023-08-02 11:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1375408.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   信息   git   display   single

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!