Re: Extracting a file
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 23, 2021, 16:47 UTC
- Message-ID
- <xmqqa6mdou3n.fsf@gitster.g>
- In-Reply-To
- <CAB9Jk9Af-GKFUQCiyN9fKmjA1hOLBw9mc_FPFBHX1m1NAnbfmQ@mail.gmail.com>
Angelo Borsotti <angelo.borsotti@gmail.com> writes:
Show 8 quoted lines
>> 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)?