20

I've looked for the answer but couldn't find it on stackoverflow, so I ask it here.
Let's assume I have some local changes since the last commit(and push) and I want to git diff of a file between a specific commit(several commits ago) and my current local version.
I mean, for example, I can see the difference of a file between two specific commits by

git diff COMMIT1 COMMIT2 src/testsuites/file1.c  

But I want to see the difference between COMMIT1 and local file. How do you do that?

1 Answer 1

25

Per the git docs:

git diff [--options] <commit> [--] [<path>…] This form is to view the changes you have in your working tree relative to the named <commit>. You can use HEAD to compare it with the latest commit, or a branch name to compare with the tip of a different branch.

So you would just do git diff COMMIT1 src/testsuites/file1.c

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.