单个修订的 git 日志

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4082126/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 09:23:35  来源:igfitidea点击:

git log of a single revision

gitgit-log

提问by zedoo

I have a commit c. I want to get the changeset of that exact commit c + metainformation and no other one. Is there a simpler way than git log -p c^..cto do that?

我有一个提交 c。我想获得那个确切的提交 c + 元信息的变更集,而不是其他的。有没有比这更简单的方法git log -p c^..c

回答by Micha? Trybus

You can use show:

您可以使用show

git show commit_id

回答by SuperFamousGuy

Michal Trybus' answer is the best for simplicity. But if you don't want the diff in your output you can always do something like:

Michal Trybus 的回答是最简单的。但是,如果您不想在输出中出现差异,您可以随时执行以下操作:

git log -1 -U c

That will give you the commit log, and then you'll have full control over all the git logging options for your automation purposes. In your instance you said you wanted the change-set. The most human-readable way to accomplish that would be:

这将为您提供提交日志,然后您将完全控制所有用于自动化目的的 git 日志记录选项。在你的例子中,你说你想要变更集。实现这一目标的最易读的方法是:

git log --name-status --diff-filter="[A|C|D|M|R|T]" -1 -U c

Or, if you're using a git version greater than 1.8.X it would be:

或者,如果您使用的是大于 1.8.X 的 git 版本,它将是:

git log --name-status --diff-filter="ACDMRT" -1 -U c

This will give you results similar to:

这会给你类似的结果:

commit {c}
Author: zedoo <[email protected]>
Date: Thu Aug 2 {time-stamp}

   {short description}
D    zedoo/foo.py
A    zedoo/bar.py

Of course you can filter out whichever events you see fit, and format the return as you wish via the traditional git-log commands which are well documented here.

当然,您可以过滤掉您认为合适的任何事件,并通过此处详细记录的传统 git-log 命令按照您的意愿格式化返回值。

回答by Robert Munteanu

git log -p c -1does just that .

git log -p c -1就是这样。

回答by natigon

You can use to filter change by description of commit:

您可以使用提交的描述来过滤更改:

git log --grep='part_of_description' -p

where git log --grep='part_of_description'select the commits that contains 'part_of_description' and -pshow the changeset of each commit

其中git log --grep='part_of_description'选择包含“part_of_description”的提交并-p显示每个提交的变更集