Get all files that have been modified in git branch

An alternative to the answer by @Marco Ponti, and avoiding the checkout:

git diff --name-only <notMainDev> $(git merge-base <notMainDev> <mainDev>)

If your particular shell doesn't understand the $() construct, use back-ticks instead.


All you have to do is the following:

git checkout <notMainDev>
git diff --name-only <mainDev>

This will show you only the filenames that are different between the two branches.


amazed this has not been said so far!

git diff main...branch

So see the changes only on branch

To check the current branch use

git diff main...

Thanks to jqr

This is short hand for

git diff $(git merge-base main branch) branch

so the merge base (the most recent common commit between the branches) and the branch tip

Also using origin/main instead of just master will help in case your local main is dated


I can't believe there are so many ways to do this. I use whatchanged as someone posted before, just with the following arguments:

git whatchanged --name-only --pretty="" origin..HEAD

This just lists the filenames, and only the ones that changed on the current branch.