Search code examples
gitgit-diff

How to list only newly added files between two branches


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?


Solution

  • 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