loading...

Git: Show staged changes

miku86 profile image miku86 Updated on ・1 min read

Git: Show staged changes

I use git add --patch a lot.

In VSCode's Source Control Tab,
you can double-click on the staged file,
and a split screen will open up with the changes side-by-side.

Alt Text

But how to do this in the terminal?

Use git diff --staged.
You can also use git diff --cached.

Alt Text

git diff --help says:

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. unborn branches) and <commit> is not given, it shows all staged changes. --staged is a synonym of --cached.

Discussion

pic
Editor guide