Restoring files from old commits

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

Restoring files from old commits

From: Nikodemus Siivola <hidden>
Date: 2016-06-15 22:43:21

What is the recommended way to restore individual files
(or directories) in the working tree to the content they
had in a given commit?

That is to say, now that Cogito is deprecated, what should
I use instead of cg-restore?

Cheers,

  -- Nikodemus

Re: Restoring files from old commits

From: martin f krafft <hidden>
Date: 2016-06-15 22:43:21

also sprach Nikodemus Siivola [off-list ref] [2007.07.14.1409 +0200]:
What is the recommended way to restore individual files
(or directories) in the working tree to the content they
had in a given commit?
As per my comment on IRC, I think

  git checkout <tree-ish> <path>

is the way.

-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
 
spamtraps: madduck.bogus@madduck.net
 
"the difference between genius and stupidity
 is that genius has it's limits."
                                                    -- albert einstein

Re: Restoring files from old commits

From: Alex Riesen <hidden>
Date: 2016-06-15 22:43:21

martin f krafft, Sat, Jul 14, 2007 14:37:54 +0200:
also sprach Nikodemus Siivola [off-list ref] [2007.07.14.1409 +0200]:
quoted
What is the recommended way to restore individual files
(or directories) in the working tree to the content they
had in a given commit?
As per my comment on IRC, I think

  git checkout <tree-ish> <path>

is the way.
It does not work for directories, though. On can use

    $ git ls-tree -r -z <tree-ish> -- <path> | git update-index -z --index-info
    $ git ls-tree -r --name-only -z <tree-ish> -- <path> | git checkout-index -f -z --stdin

for a more generic way to do this.

P.S. Martin, would you please stop removing people from address lists
and stop using that Mail-Followup-To? People miss their mails when
they are not addressed to them anymore and you doing exactly that.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help