Suppose we have a git repository that contains two images: alice.png
and bob.png
. We commited this in Initial commit
.
After that, we do cp bob.png alice.png
, so alice.png
will have the same content with bob.png
.
Doing git diff
shows that.
Now if I open alice.png
I see Bob. How can I open/read/access programatically the old alice.png
(which appears if I do git checkout alice.png
)?
The best (which is not a good one) solution I found is to:
- copy the repository into a temp directory
- do
git checkout .
- get modified files from original directory
- read the non-modified files from temp directory
But I suppose there should be a better solution.
For non-binary files git show HEAD:path/to/file
does this, but for me, when doing git show HEAD:alice.png
nothing is output.