Git显示合并提交,列出的文件比合并的文件多。

huangapple go评论60阅读模式
英文:

Git Show of a merge commit listing more files than the merged files

问题

我有3个特性分支和1个发布分支。我将来自Feature1的代码合并到Release,有2个提交。然后我正在将来自Feature2的代码合并到Release,有1个提交。当我执行git show命令来查看第2个合并提交时,它列出了所有文件,而不是仅显示Feature2合并的文件。

我希望我的合并提交ID只列出特定分支合并的文件,而不是显示所有文件。如果您不明白我的问题,请回复。

英文:

I have 3 Feature branches and 1 Release branch. I merged code from Feature1 to Release having 2 commits. Then i am merging code from feature2 to Release having 1 commit. When i execute the git show command with 2nd merge commit its listing all the files instead of showing only feature2 merged files.

git show -m -1 6929195e --name-only --stat --pretty=format:

I want my merge commit id to list only merged files from particular branch instead of showing all the files. Please reply if you dont understand my questions.

答案1

得分: 1

如果您只想列出已更改的文件,可以使用 git diff <SHA>^1 <SHA>

在您的情况下:

git diff --name-only 6929195e^1 6929195e

灵感来自于这篇文章

英文:

If you want to list only changed files you could use git diff <SHA>^1 <SHA>

If your case:

git diff --name-only 6929195e^1 6929195e

Inspired by this article

答案2

得分: 1

如果您的最后提交是在将feature2合并到master之后生成的合并提交,那么您可以使用以下命令获取从feature2合并的文件列表:

git show --first-parent <merge-commit-SHA> --name-only --pretty=format:
英文:

If your last commit is a merge commit generated after merging feature2 into master, then you can use the following command to get the list of merged files from the feature2:

git show --first-parent &lt;merge-commit-SHA&gt; --name-only --pretty=format:

huangapple
  • 本文由 发表于 2020年1月3日 14:52:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/59574344.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定