For Staging Area vs Repository(last commit) comparison use
$git diff --staged
The command compares your staged($ git add fileName
) changes to your last commit. If you want to see what you’ve staged that will go into your next commit, you can use git diff --staged. This command compares your staged changes to your last commit.
For Working vs Staging comparison use
$ git diff
The command compares what is in your working directory with what is in your staging area. It’s important to note that git diff by itself doesn’t show all changes made since your last commit — only changes that are still unstaged. If you’ve staged all of your changes($ git add fileName
), git diff will give you no output.
Also, if you stage a file($ git add fileName
) and then edit it, you can use git diff to see the changes in the file that are staged and the changes that are unstaged.