Thread (1 message) 1 message, 1 author, 2021-07-23
  • (off-list ancestor, not in this archive)
  • Re: Extracting a file · Junio C Hamano <hidden> · 2021-07-23

Re: Extracting a file

From: Junio C Hamano <hidden>
Date: 2021-07-23 16:47:28

Angelo Borsotti [off-list ref] writes:
quoted
You might also like "git checkout -p HASH -- A", which will let you pick
individual hunks from HASH:A and apply them to your working tree.
This shows the differences between the committed and the current file,
in a patch
form, which is handy to apply to the current file to make it equal to
the old, but
not if I want to browse the old file and understand how it was before.
Why doesn't a straight-forward "check out the path from an old
version" work?  That is

    git checkout $old_version -- path/to/file.ext

Is it because you have changes to path/to/file.ext already (in which
case "mv path/to/file.ext path/to/file.ext-saved" would be a quick
way to save it away)?

And then path/to/file.ext can be inspected to your heart's content,
and when you are done and want to go back to the current state, you
can do "git checkout HEAD -- path/to/file.ext" (followed by the
earlier "mv" in reverse)?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help