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

Re: Restoring files from old commits

From
NSNikodemus Siivola <nikodemus@random-state.net>
Date
Aug 15, 2007, 17:22 UTC
Message-ID
<6bcc356f0708151022v6cb8c348nb19690c81e489c5d@mail.gmail.com>
In-Reply-To
<20070715084141.GA2568@steel.home>
Tangentially related to my previous question:

Every once and a while I want to examine an older version of a file in an editor.

(The typical case is first looking for the source of a change with git-blame, and then wanting to look at the original code and the diff side by side.)

My current (suboptimal, I hope!) way of doing getting the file is git-cat-file: first look at the commit, then look at the tree, ... till I find the SHA1 for the file I want.

git-checkout <sha1-of-commit> <path>, but that leaves the old version in both the index and the tree, which feels icky especially if I'm giving this treatment to multiple files at the same time.

So what I'd like is something like
 git cat-path <commit> <path-in-the-tree-referenced-by-that-commit>
Does this exist, or is this scripting time?
Cheers,
 -- Nikodemus
Previous: Alex RiesenNext: Salikh Zakirov
Message 6 of 8 in “Restoring files from old commits”
  1. Nikodemus SiivolaJul 14, 2007
  2. martin f krafftJul 14, 2007
  3. Alex RiesenJul 14, 2007
  4. Junio C HamanoJul 14, 2007
  5. Alex RiesenJul 15, 2007
  6. Nikodemus SiivolaAug 15, 2007
  7. Salikh ZakirovAug 15, 2007
  8. Uwe Kleine-KönigAug 15, 2007

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.