This command contrasts the contents of the files in your current working directory with those found in the last commit (referred to as HEAD
).
It effectively gives you a summary of all the changes that you've made but not yet committed to the repository.
It includes information such as additions (marked with +
) and subtractions (recognized by -
). For comparing with other commits or branches, simply replace HEAD
with the desired commit hash or branch name. For example, git diff HEAD~1
compares with one commit before the last.
Moreover, you can use --stat
to see a summary instead of the full diff, or --color-words
to see changes at the word level, instead of by line.