![Forrest logo](/images/logo.png)
git-diff:tldr:ec801
git-diff: Show all uncommitted changes (including staged ones).
$ git diff HEAD
try on your machine
The command "git diff HEAD" is used to view the difference between the current working directory and the latest commit in the Git repository.
Here's what each part of the command means:
git diff
: This is the Git command to view the difference between two points in history.HEAD
: In Git, "HEAD" is a reference to the latest commit on the current branch. It represents the tip of the branch and points to the most recent commit.
So, when you use "git diff HEAD", Git compares the changes you have made in your working directory (all the modified, added, or deleted files) with the latest commit. It displays the differences line by line, highlighting additions in green and deletions in red.
This command is useful to review your changes before committing them. It helps you see what modifications you have made, allowing you to decide which changes to include in your next commit.
This explanation was created by an AI. In most cases those are correct. But please always be careful and
never run a command you are not sure if it is safe.