Difference between a git commit and the working directory?

Yes, but it depends a bit on your definition on what the “current project state” is. The manual for git diff goes on.

If you are interested in comparing with the staged changes:

git diff [--options] --cached [<commit>] [--] [<path>...]

This form is to view the changes you staged for the next commit relative to the named <commit>. Typically you would want comparison with the latest commit, so if you do not give <commit>, it defaults to HEAD. If HEAD does not exist (e.g. unborned branches) and <commit> is not given, it shows all staged changes. --staged is a synonym of --cached.

If you are interested in comparing with the unstaged changes:

git diff [--options] <commit> [--] [<path>...]

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.

Or if you are just interested in comparing any two commits (one could be HEAD):

git diff [--options] <commit> <commit> [--] [<path>...]

This is to view the changes between two arbitrary <commit>s.

So you might want to run git diff someOldCommit HEAD to see the differences between someOldCommit and the current HEAD.


It ist just simple:

git diff HEAD

Explanation: Current changes in the working directory compared with the last commit.

Tags:

Git Diff