Show diff between commits
I am using Git on Ubuntu 10.04 (Lucid Lynx).
I have made some commits to my master.
However, I want to get the difference between these commits. All of them are on my master branch.
commit dj374 made changes commit y4746 made changes commit k73ud made changes
I want to get the difference between k73ud and dj374. However, when I did the following I couldn't see the changes I made in
git diff k73ud..dj374 > master.patch
git diff k73ud^..dj374
to make sure to include all changes of
k73ud in the resulting diff.
git diff compares two endpoints (instead of a commit range).
Since the OP want to see the changes introduced by
k73ud, he/she needs to difference between the first parent commit of
That way, the
diff results will include changes since
k73ud parent (meaning including changes from
k73ud itself), instead of changes introduced since
k73ud (up to
Also you can try:
git diff oldCommit..newCommit git diff k73ud..dj374
and (1 space, not more):
git diff oldCommit newCommit git diff k73ud dj374
And if you need to get only files names (e.g. to copy hotfix them manually):
git diff k73ud dj374 --name-only
And you can get changes applied to another branch:
git diff k73ud dj374 > my.patch git apply my.patch
To see the difference between:
Your working copy and staging area:
% git diff
Staging area and the latest commit:
% git diff --staged
Your working copy and commit 4ac0a6733:
% git diff 4ac0a6733
Commit 4ac0a6733 and the latest commit:
% git diff 4ac0a6733 HEAD
Commit 4ac0a6733 and commit 826793951
% git diff 4ac0a6733 826793951
For more explanation see the official documentation.
Read more... Read less...
If you want to see the changes introduced with each commit, try "git log -p"
- Select the first commit
- Right click on the other, then diff selected → this
gitk to see the difference:
It has a GUI mode so that reviewing is easier.
To see the difference between two different commits (let's call them
git diff a..b
- Note that the difference between
bis opposite from
To see the difference between your last commit and not yet committed changes, use
If you want to be able to come back to the difference later, you can save it in a file.
git diff a..b > ../project.diff
Simplest for checking the changes in the last 2 commits after pull:
git diff HEAD~2