Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git diff between specific commit and local file

Tags:

git

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?

like image 594
Chan Kim Avatar asked Jul 09 '15 04:07

Chan Kim


1 Answers

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

like image 110
dnapierata Avatar answered Oct 15 '22 08:10

dnapierata