To compare the staged with the last commit:
git diff --cached git diff --staged
Both commands generate the same results, right?
git diff --cached --merge-base A is equivalent to git diff --cached $(git merge-base A HEAD) . 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.
git diff --staged will only show changes to files in the "staged" area. git diff HEAD will show all changes to tracked files. If you have all changes staged for commit, then both commands will output the same.
--staged is a synonym of --cached . Stage/cache/index are all synonyms for the staging area.
If your changes are already staged, then there's no difference to show. But there's a command line option that will show you staged changes if you specify it: git diff --staged . With the --staged option, git diff will compare your staged changes against the previous commit.
The documentation for git diff
says "--staged
is a synonym of --cached
", so yes.
From the docs - --staged is a synonym of --cached
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