Forrest logo
back to the git tool

git-diff:tldr:d27d3

git-diff: Show only staged (added, but not yet committed) changes.
$ git diff --staged
try on your machine

The command "git diff --staged" is used to view the changes that have been staged or added to the Git index. It displays the differences between the files in the current working directory and the files that have been staged but not yet committed.

Here is a breakdown of what each part of the command does:

  • "git diff": This is the base command used to view the differences between different states of a Git repository. By default, it compares the changes between the working directory and the most recent commit.

  • "--staged": This flag, also known as "--cached", tells Git to compare the differences between the staging area (the Git index) and the most recent commit. It specifically shows the changes that have been added to the index but not yet committed.

By running "git diff --staged", you can see the specific changes made to the tracked files that are currently staged for the next commit. This allows you to review your changes before finalizing the 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.
back to the git tool