Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to get git diff with commit changes in single command

Tags:

git

Is there any way we can get the details of diff of a file along with it's commit ID details through a single command ? Currently , "git diff tag1..tag2" gives me the entire code change between the two tags but not the commit ID and reasons for commit . When i use " git log " it gives me complete commit change with changes that i'm not concerned with when comparing two tags .

like image 585
Vinz Avatar asked Aug 02 '11 10:08

Vinz


1 Answers

but this change also has a commit ID and commit reason which i want in the same diff file

I think there is a little confusion here. The git-diff outputs the difference between one commit and another, that difference is not just one commit, it represents a series of commits in the range you specify (662a1fa..64f9766 in the example you gave). So that would be multiple commit IDs and messages, perhaps even thousands if your tags are far enough apart.

If git diff were to output all the associated commit messages you would have no good way of telling which part of the diff is associated with each commit ID and commit message. This is why git log exists.

Git log does display each commit one after another in the range you specify and so that's why it will display commit messages.

git-diff shows you the difference between a and z.
git-log shows you the journey a took to become z.

With that in mind, I'm guessing this is probably what you are looking for:

git log --color -p --full-diff tag1..tag2

like image 191
Gerry Avatar answered Sep 21 '22 15:09

Gerry