GIT - How to list only newly added files between two branches

我的梦境 提交于 2019-11-30 11:55:43

问题


how can I list newly created(added) files between two branches? I can list all files that have been changed with:

git diff --color --name-only branch1..branch2

But that also contains files, that just changed their content, not necessarily new files. Is there some git command for this, or do I have to checkout each branch and compare the files, e.g. with bash? Thanks.

Filip


回答1:


Just replace --name-only with --name-status. This way git will show if the file is added, deleted or just modified.

If you are only interested in the new (=added) files you can simply grep for ^A:

git diff --name-status branch1..branch2 | grep ^A



回答2:


You can use --diff-filter option of git diff:

git diff --color --name-only --diff-filter=A branch1 branch2



回答3:


Use this command to check for new tracked/added files

git diff --color --name-status staging | grep ^A


来源:https://stackoverflow.com/questions/19222708/git-how-to-list-only-newly-added-files-between-two-branches

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