Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Diffing two branches to show changes introduced in one branch

Tags:

git

diff

I know about git diff branch1 branch2. However, I would like to see changes introduced in one branch only. I can get this functionality with:

git checkout branch1
git merge branch2
git reset origin/branch1
git diff

Is there a shorter way to do this?

like image 263
Vlad the Impala Avatar asked Jun 22 '12 19:06

Vlad the Impala


1 Answers

You can do:

git diff branch1...branch2

(note that there are three dots)

... which will show you all the changes introduced on branch2 since it diverged from branch1 (or, strictly speaking, since the merge-base). The different uses of .. and ... in git diff and git log, can be a bit confusing, so you might find the diagrams in this answer helpful.

like image 135
Mark Longair Avatar answered Sep 29 '22 00:09

Mark Longair