how to show differences between some or all files? GIT

git diff

Will show you the pending modified changes of un committed files

Review the docs on this command for the many different ways you can use it to see the differences between files


Or perhaps a bit more helpful:

git diff <commit1> <commit2> -- path/to/file.cpp path/to/anotherfile.cpp path/to/subdir

You can also (in e.g. bash)

git diff {<commit1>,<commit2>}:path/to/file.cpp

This way you can even

git diff <commit1>:path/to/file.cpp <commit2>:path/to/anotherfile.cpp

which is quite insane powerful, IMHO.

Replace <commit1> and <commit2> by any name of tag, branch (local or remote) or direct sha1 hash of a commit (this is known as a commit-ish)

To get really funky, you can specify tree-ish or blob hashes if you want. Do something completely silly with this for a sample:

$ git ls-tree HEAD^ | grep blob | sort -R | head -2
100644 blob 27785581e788049ac805fab1d75744dd7379735d    .gitignore
100644 blob 2821a5271ffd8e6b11bb26b8571f57e88ab81f38    TESTING

$ git diff --stat 2821a5271ffd8e6b11bb26b8571f57e88ab81f38 aa96765714a3058068c4425d801fab4b64e26066
 ...f38 => aa96765714a3058068c4425d801fab4b64e26066 |  155 +++++++++++++++++---
 1 files changed, 135 insertions(+), 20 deletions(-)

Now you won't usually do this, unless you have several versions of the 'same' file in you repo (which is iffy, if you ask me).

Tags:

Git