git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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)?

Previous: Angelo BorsottiNext: Junio C Hamano
Message 6 of 8 in “Extracting a file”
  1. Angelo BorsottiJul 22, 2021
  2. Ævar Arnfjörð BjarmasonJul 22, 2021
  3. Angelo BorsottiJul 22, 2021
  4. Jeff KingJul 23, 2021
  5. Angelo BorsottiJul 23, 2021
  6. Junio C HamanoJul 23, 2021
  7. Junio C HamanoJul 23, 2021
  8. Felipe ContrerasJul 23, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.