As in the subject: how to show differences betwen some or all files?
Sorry i've screwed up my question. I meant differences betwen branches for one or multiple or all files.
You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch. Order does matter when you're comparing branches.
Comparing changes with git diff Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
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).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With