Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - Diff between branches in old commits

I have this:

branch: commit 1, commit 2, 3,4
master: commit 1, commit 2, 3,4,5,6,7

How can you make a diff between branch after commit 2 (in that point of history) and master in commit 3?

like image 722
joel Avatar asked Oct 26 '25 14:10

joel


2 Answers

Let's name your commits b1, b2, b3, b4; m1, m2, m3, m4, m5, m6, m7. To diff two commits you can run git diff commit1 commit2. In your case it's git diff b2 m3.

like image 139
phd Avatar answered Oct 29 '25 03:10

phd


You can always and in any time check the difference between commits with

git diff commit1..commit2

You can substitute commit with branch names.

git diff master..foo

or also with HEAD

git diff master..HEAD

and so on.

Here a real example:

git diff e8e1956c174da9d..90f2b3ee988d8b6

Note that the complete hash is not necessary.

like image 21
sensorario Avatar answered Oct 29 '25 03:10

sensorario



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!