loading...

Git: Show staged changes

miku86 profile image miku86 Updated on ・1 min read

Shorties (8 Part Series)

1) Git: Show staged changes 2) Bash: Rename specific files in a folder 3 ... 6 3) VSCode: Transform text to lowercase/uppercase/titlecase 4) Git: How to move misallocated commits 5) Git: Find specific, deleted content in a file 6) Git: Delete merged branches 7) A Tool to Write Simple Notes 8) Find all files with a specific name and show their file size

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.

Shorties (8 Part Series)

1) Git: Show staged changes 2) Bash: Rename specific files in a folder 3 ... 6 3) VSCode: Transform text to lowercase/uppercase/titlecase 4) Git: How to move misallocated commits 5) Git: Find specific, deleted content in a file 6) Git: Delete merged branches 7) A Tool to Write Simple Notes 8) Find all files with a specific name and show their file size

Posted on by:

miku86 profile

miku86

@miku86

Mentor & Educator & Senior Web Developer - I help people to reach their (career) goals. => https://miku86.com/mentoring

Discussion

markdown guide