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
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
also sprach Nikodemus Siivola <nikodemus@random-state.net> [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 einsteinRe: Restoring files from old commits
martin f krafft, Sat, Jul 14, 2007 14:37:54 +0200:
> also sprach Nikodemus Siivola <nikodemus@random-state.net> [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.
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 --stdinfor 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.
Re: Restoring files from old commits
Alex Riesen <raa.lkml@gmail.com> writes:
> martin f krafft, Sat, Jul 14, 2007 14:37:54 +0200: >> also sprach Nikodemus Siivola <nikodemus@random-state.net> [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. > > It does not work for directories, though.
Are you sure about that? I just did this in my git.git workspace:
$ mv Documentation Documentation-
$ git checkout HEAD Documentation/
$ diff -r Documentation- DocumentationRe: Restoring files from old commits
Junio C Hamano, Sat, Jul 14, 2007 20:50:49 +0200:
> Alex Riesen <raa.lkml@gmail.com> writes: > > > > It does not work for directories, though. > > Are you sure about that? I just did this in my git.git workspace: > > $ mv Documentation Documentation- > $ git checkout HEAD Documentation/ > $ diff -r Documentation- Documentation >
Missed it. Happy now :)
Re: Restoring files from old commits
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
Re: Restoring files from old commits
Nikodemus Siivola пишет:
> 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?
Have you tried
git show <commit>:<path>
?
Re: Restoring files from old commits
Hello Nikodemus,
Nikodemus Siivola wrote:
> So what I'd like is something like > > git cat-path <commit> <path-in-the-tree-referenced-by-that-commit>
Try:
git show <commit>:<path-in-the-tree-referenced-by-that-commit>
Best regards Uwe
-- Uwe Kleine-König http://www.google.com/search?q=half+a+cup+in+teaspoons