Skip to content
Fix Code Error

How do I show the changes which have been staged?

March 13, 2021 by Code Error
Posted By: Anonymous

I staged a few changes to be committed; how can I see the diff of all files which are staged for the next commit? I’m aware of git status, but I’d like to see the actual diffs – not just the names of files which are staged.

I saw that the git-diff(1) man page says

git diff [–options] [–] […]

This form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you could tell git to further add to the index but you still haven’t. You can stage these changes by using git-add(1).

Unfortunately, I can’t quite make sense of this. There must be some handy one-liner which I could create an alias for, right?

Solution

It should just be:

git diff --cached

--cached means show the changes in the cache/index (i.e. staged changes) against the current HEAD. --staged is a synonym for --cached.

--staged and --cached does not point to HEAD, just difference with respect to HEAD. If you cherry pick what to commit using git add --patch (or git add -p), --staged will return what is staged.

Answered By: Anonymous

Related Articles

  • Checkout another branch when there are uncommitted changes…
  • Why am I getting a "401 Unauthorized" error in Maven?
  • npm install error in vue
  • How to recover stashed uncommitted changes
  • Various ways to remove local Git changes
  • git pull while not in a git directory
  • Fix top buttons on scroll of list below
  • In plain English, what does "git reset" do?
  • center 3 items on 2 lines
  • Interdependent properties in Vue.js

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Redefine tab as 4 spaces

Next Post:

Fatal error: Maximum execution time of 30 seconds exceeded

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Get code errors & solutions at akashmittal.com
© 2022 Fix Code Error