DEV Community

miku86
miku86

Posted on • Updated on

Git: Show staged changes

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.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)