* Restoring files from old commits
@ 2007-07-14 12:09 Nikodemus Siivola
2007-07-14 12:37 ` martin f krafft
0 siblings, 1 reply; 8+ messages in thread
From: Nikodemus Siivola @ 2007-07-14 12:09 UTC (permalink / raw)
To: git-list
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Restoring files from old commits
2007-07-14 12:09 Restoring files from old commits Nikodemus Siivola
@ 2007-07-14 12:37 ` martin f krafft
2007-07-14 14:32 ` Alex Riesen
0 siblings, 1 reply; 8+ messages in thread
From: martin f krafft @ 2007-07-14 12:37 UTC (permalink / raw)
To: git-list
[-- Attachment #1: Type: text/plain, Size: 644 bytes --]
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 einstein
[-- Attachment #2: Digital signature (GPG/PGP) --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Restoring files from old commits
2007-07-14 12:37 ` martin f krafft
@ 2007-07-14 14:32 ` Alex Riesen
2007-07-14 18:50 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Alex Riesen @ 2007-07-14 14:32 UTC (permalink / raw)
To: git; +Cc: Nikodemus Siivola, martin f krafft
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 --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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Restoring files from old commits
2007-07-14 14:32 ` Alex Riesen
@ 2007-07-14 18:50 ` Junio C Hamano
2007-07-15 8:41 ` Alex Riesen
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2007-07-14 18:50 UTC (permalink / raw)
To: Alex Riesen; +Cc: git, Nikodemus Siivola, martin f krafft
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- Documentation
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Restoring files from old commits
2007-07-14 18:50 ` Junio C Hamano
@ 2007-07-15 8:41 ` Alex Riesen
2007-08-15 17:22 ` Nikodemus Siivola
0 siblings, 1 reply; 8+ messages in thread
From: Alex Riesen @ 2007-07-15 8:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Nikodemus Siivola, martin f krafft
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 :)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Restoring files from old commits
2007-07-15 8:41 ` Alex Riesen
@ 2007-08-15 17:22 ` Nikodemus Siivola
2007-08-15 17:28 ` Salikh Zakirov
2007-08-15 18:27 ` Uwe Kleine-König
0 siblings, 2 replies; 8+ messages in thread
From: Nikodemus Siivola @ 2007-08-15 17:22 UTC (permalink / raw)
To: git
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Restoring files from old commits
2007-08-15 17:22 ` Nikodemus Siivola
@ 2007-08-15 17:28 ` Salikh Zakirov
2007-08-15 18:27 ` Uwe Kleine-König
1 sibling, 0 replies; 8+ messages in thread
From: Salikh Zakirov @ 2007-08-15 17:28 UTC (permalink / raw)
To: git
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>
?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Restoring files from old commits
2007-08-15 17:22 ` Nikodemus Siivola
2007-08-15 17:28 ` Salikh Zakirov
@ 2007-08-15 18:27 ` Uwe Kleine-König
1 sibling, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2007-08-15 18:27 UTC (permalink / raw)
To: Nikodemus Siivola; +Cc: git
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
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-08-15 18:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-14 12:09 Restoring files from old commits Nikodemus Siivola
2007-07-14 12:37 ` martin f krafft
2007-07-14 14:32 ` Alex Riesen
2007-07-14 18:50 ` Junio C Hamano
2007-07-15 8:41 ` Alex Riesen
2007-08-15 17:22 ` Nikodemus Siivola
2007-08-15 17:28 ` Salikh Zakirov
2007-08-15 18:27 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).