Checkout file without changing index?
- Date: Wed, 24 Apr 2019 15:37:05 +0200
- From: Piotr Krukowiecki <piotr.krukowiecki@xxxxxxxxx>
- Subject: Checkout file without changing index?
what is the standard/recommended way for updating a file to given version?
I was familiar with "git checkout revision -- file".
But it updates both working tree and index. I had some changes in
index (staged) and "git checkout HEAD -- file" silently overwritten
it. Well, probably my mistake, it's documented.
After searching a bit I found "git show revision:file > file". But
1. works only for 1 file. "git show revision -- file" does something else
2. requires full path, so you need to specify "git show
If there's no other easy way, maybe we could add "--no-index" to
checkout: "git checkout --no-index revision -- file" (or similar -
maybe use options from git-reset).
My use case: I had some changes prepared in index and wanted to
compare the prepared version with some older version. The file was a
zip file plus we use LFS so there was no other way than to "checkout"
the file, unpack it and diff it.