How to Show the Changes which Have Been Staged in Git

There might be cases when, after staging several changes to be committed, you wish to see the differences of all the files staged for the next commit. Here, we suggest you simple solutions to use and succeed.

Watch a course Git & GitHub - The Practical Guide

How to show changes using git diff

Run git diff with --cached option, which shows the staged changes for the next commit, related with the HEAD:

git diff --cached

The --staged option is synonymous with the --cached option.

If you want to see only the file names, then run the same command with the --name-only option:

git diff --name-only --cached

How to show changes using git status

The git status command has --verbose(same as -v) option, which shows the changes, staged for the next commit:

git status -v

The git diff Command

The git diff command displays the changes between the working directory and the staging area. It is used in combination with git status and git log commands for analyzing the state of a git repository. The --cached option displays the changes between the staging area and the HEAD. It shows what has been added to the staging area and staged for a commit.

The git diff HEAD command shows all the changes made between the working directory and HEAD, including changes in the staging area. It displays all the changes since the last commit, whether staged for commit or not.

The git status Command

The git status command is run to show the state of the working directory and the staging area. It makes it possible to view the staged changes and the files not being tracked by Git. The status output does not show any information about the committed project history. Use the git log command instead. The -- verbose option not only shows the names of changed files but also displays the textual changes staged to be committed. The -v option defined twice will show not staged changes in the working tree.