1

I added a file to the index. And edit this file in working tree. There is two different versions of the file. I want to see version from index.

How to do it easiest?

==============
Duplicates:
How can I get content of a file from git index?
Git: Show content of file as it will look like after committing

Community
  • 1
  • 1
Aleks Ya
  • 859
  • 5
  • 15
  • 27

3 Answers3

3
git show :file

shows the version of file in the index. It prints it out or pipes it to your configured pager.

Alternatively, you can check out the index version to a temporary subdirectory with something like:

git checkout-index --prefix=tmp/ file
CB Bailey
  • 755,051
  • 104
  • 632
  • 656
0

Use git diff --cached <path to file>.
This will show you the differences which are on the index.

Take a look at the documentation.

Sascha Wolf
  • 18,810
  • 4
  • 51
  • 73
  • Yes, it shows difference, but I need see whole file content. Do you now how to do it? – Aleks Ya Jul 16 '14 at 08:11
  • @AleksYa Use `git show :` then. This will print the indexed version of the file on the console. – Sascha Wolf Jul 16 '14 at 08:17
  • @AleksYa Take a look at [this question](http://stackoverflow.com/questions/5153199/git-show-content-of-file-as-it-will-look-like-after-committing) for more information. – Sascha Wolf Jul 16 '14 at 08:18
0

As you mentioned - once you adding file to the index you can continue and modify it while the indexed version remains unchanged.

In order to view the index content you have to use

git show :<file>

The : are mandatory and you must have them in your cli command

CodeWizard
  • 128,036
  • 21
  • 144
  • 167