1

So let's say I've already run git add -p and I've selected the hunks I'd like to add to the file, and the hunks I would not like to add to the file. How can I see the resulting file in full based on what is about to be committed without committing it?

I tried using git diff --staged as linked above but it only shows me the changes staged for commit, and not the full resulting file that will be committed to my local repository. Or should I just not worry about that, commit anyway and then undo the last commit?

Community
  • 1
  • 1
leeand00
  • 25,510
  • 39
  • 140
  • 297

1 Answers1

1

You should b able to see the file currently cached (staged) with:

git show :file

git show uses gitrevisions

:path (with an empty part before the colon) is a special case of the syntax: content recorded in the index at the given path.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Just for the record, if you don't include the `:` before the filename it doesn't work; but if you do, it does. – leeand00 Oct 13 '15 at 13:54
  • 1
    @leeand00 I agree. That is why I mention the special syntax `:path` in the answer: the '`:`' is important. – VonC Oct 13 '15 at 13:59