在 git merge commit 中列出所有修改过的文件 - 即使是快进的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14717120/
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 15:26:28  来源:igfitidea点击:

List all modified files in git merge commit - even the fast forwarded

gitmergegit-branchgit-merge

提问by soupdiver

I'm thinking if there is a way that when I merge a branch into another branch that ALL changed files are listed in my commit message and not just the ones which were modified in both branches. This would give me a better overview of what was changed in the branch just by seeing the merge commit. Is there a way to do this?

我在想是否有一种方法可以在我将一个分支合并到另一个分支时,所有更改的文件都列在我的提交消息中,而不仅仅是在两个分支中修改的文件。通过查看合并提交,这将使我更好地了解分支中的更改内容。有没有办法做到这一点?

回答by Schleis

I don't know how to do that in the commit message. But after the merge, this will give the names of all the files affected by the merge commit:

我不知道如何在提交消息中做到这一点。但是在合并之后,这将给出受合并提交影响的所有文件的名称:

git log -m --name-only

For only a list of filenames of the commit:

仅用于提交的文件名列表:

git log -m -1 --name-only --pretty="format:" <Merge SHA>

There is some white space due to the merge having two parents but that can be easily removed.

由于合并有两个父级,因此存在一些空白,但可以轻松删除。

回答by R0MANARMY

You can also use the diffcommand to see the difference between any two commits. If the branches haven't been merged yet, you can specify the branch names and compare them, otherwise you might need to find where they diverged (like so)an the last commit before they were merged back together.

您还可以使用该diff命令查看任意两次提交之间的差异。如果分支尚未合并,您可以指定分支名称并比较它们,否则您可能需要找到它们分歧的位置就像这样,以及在它们合并回一起之前的最后一次提交。

git diff --name-status <commit> <commit>

-name-statusShow only names and status of changed files.?

-name-status仅显示更改文件的名称和状态。?

回答by evgenii

suppose you have SHA of your merge commit, then git diff --name-only <SHA>^1 <SHA>

假设你有你的合并提交的 SHA,那么 git diff --name-only <SHA>^1 <SHA>