This will show the unstaged changes on the current branch from the commit before it. It will only show changes
relative to the index, meaning it shows what you could add to the next commit, but haven't. To add (stage) these
changes, you can use git add.
If a file is staged, but was modified after it was staged, git diff will show the differences between the current file
and the staged version.
git diff 1234abc..6789def # old new
E.g.: Show the changes made in the last 3 commits:
git diff @~3..@ # HEAD -3 HEAD
Note: the two dots (..) is optional, but adds clarity.
This will show the textual difference between the commits, regardless of where they are in the tree
git diff --staged
This will show the changes between the previous commit and the currently staged files.
NOTE: You can also use the following commands to accomplish the same thing:
git diff --cached
Which is just a synonym for --staged or
git status -v
Which will trigger the verbose settings of the status command.
Show the changes between the tip of new and the tip of original:
git diff original new # equivalent to original..new
Show all changes on new since it branched from original:
git diff original...new # equivalent to $(git merge-base original new)...new
To show all staged and unstaged changes, use:
git diff HEAD
NOTE: You can also use the following command:
git status -vv
git diff myfile.txt
Shows the changes between the previous commit of the specified file (myfile.txt) and the locally-modified version
that has not yet been staged.
This also works for directories:
git diff documentation
The above shows the changes between the previous commit of all files in the specified directory (documentation/)
and the locally-modified versions of these files, that have not yet been staged.
To show the difference between some version of a file in a given commit and the local HEAD version you can specify
the commit you want to compare against:
git diff 27fa75e myfile.txt
Or if you want to see the version between two separate commits:
git diff 27fa75e ada9b57 myfile.txt
git difftool -t meld --dir-diff
will show the working directory changes. Alternatively,
git difftool -t meld --dir-diff [COMMIT_A] [COMMIT_B]
will show the differences between 2 specific commits