GIT - 如何只列出两个分支之间新添加的文件 [英] GIT - How to list only newly added files between two branches
问题描述
如何在两个分支之间列出新建(添加)的文件?我可以列出所有已更改的文件:
git diff --color --name-only branch1..branch2
但是,这也包含文件,只是改变了他们的内容,不一定是新文件。是否有一些git命令,或者我必须检出每个分支并比较文件,例如用bash?谢谢。
Filip
> - 仅限名称与 - 名称状态
。这样git会显示文件是否被添加,删除或者只是修改。
如果你只对新的(=添加的)文件感兴趣,你可以简单地grep for ^ A
:
git diff --name-status branch1..branch2 | grep ^ A
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
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
这篇关于GIT - 如何只列出两个分支之间新添加的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!