Get all files that have been modified in git branch

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


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.


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.

Tags:

Branch

Git