git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Checkout file without changing index?
@ 2019-04-24 13:37 Piotr Krukowiecki
  2019-04-24 13:46 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Piotr Krukowiecki @ 2019-04-24 13:37 UTC (permalink / raw)
  To: git

Hi,

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
it's problematic:
1. works only for 1 file. "git show revision -- file" does something else
2. requires full path, so you need to specify "git show
revision:relative/to/top/dir/file"

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.

-- 
Piotr Krukowiecki

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-25  4:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 13:37 Checkout file without changing index? Piotr Krukowiecki
2019-04-24 13:46 ` Junio C Hamano
2019-04-24 18:15   ` Piotr Krukowiecki
2019-04-24 20:16     ` Philip Oakley
2019-04-25  3:40   ` Sitaram Chamarty
2019-04-25  4:02     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).