Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-diff

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

like image 744
Filip Majernik Avatar asked Oct 07 '13 10:10

Filip Majernik


People also ask

How do I display only the names of changed files?

git show --name-only SHA1 . you can also do: git diff --name-only HEAD@{3} HEAD@{0} for the exact commits you want to compare.


2 Answers

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

git diff --color --name-only --diff-filter=A branch1 branch2 
like image 142
Jakub Narębski Avatar answered Sep 23 '22 01:09

Jakub Narębski


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 
like image 32
michas Avatar answered Sep 24 '22 01:09

michas