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

给你一囗甜甜゛ 提交于 2019-11-27 11:53:28

问题


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?


回答1:


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.




回答2:


You can also use the diff command 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.

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

-name-status Show only names and status of changed files. 




回答3:


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



来源:https://stackoverflow.com/questions/14717120/list-all-modified-files-in-git-merge-commit-even-the-fast-forwarded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!