git – Diff between must commits

Question:

I'm doing a git diff between two commits and in general it shows me the difference between the files that have been modified in those commits.

EX:

git diff 1a1a1a 4d4d4d

+              Essa linha foi adicionada
-              Essa linha foi removidada

This works perfectly, and I have nothing to complain about. The point is that between these commits there are other commits! And that's exactly what I want.

Ex:

commit 1a1a1a
Author: Gabriel Hardoim

     Commit 1A

commit 2b2b2b
Author: Gabriel Hardoim

     Commit 2B      // Esse commit me interessa

commit 3c3c3c
Author: Gabriel Hardoim

     Commit 3C      // Esse também

commit 4d4d4d
Author: Gabriel Hardoim

     Commit 4D

With that in mind, how can I do a for each between the first and last commit? Does git have any commands that can help me in this case?

Answer:

Use .. between commits:

git diff 1a1a1a..4d4d4d

Or :

git diff 1a1a1a^..4d4d4d

Whether to include the differences from the initial commit 1a1a1a .

Without .. , you get only the differences between only two commits , and not all of the commits between them.

Scroll to Top