Question

I've been playing with git diff a little bit and I can't seem to find a way to compare two branches for new/modified/deleted files coming only from my branch.

Let's says we got master and dev, which is the branch I'm working on. I would like to git diff them but only get what I modified in dev compared to master.

Was it helpful?

Solution

Perhaps this is what you're looking for:

git diff --name-status master dev

See git help diff for a full explanation of all the possible flags at the beginning of each line, but the most frequent would be (A)dded, (D)eleted and (M)odified...

Edit: Actually, if you want to get only the changes made on dev, then the above command will work, but you don't want to compare dev to the current head of master, but to the place where dev diverged from master, which is generally the same as git merge-base master dev. So the above command would be changed to:

git diff --name-status $(git merge-base master dev) dev
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top