{"thread":{"id":"6266","subject":"Simple UI question...","startedAt":"2007-01-07T11:02:59Z","lastAt":"2007-01-07T11:50:52Z","messageCount":9,"participants":["Chris Lee","Shawn O. Pearce","Junio C Hamano","Josef \"Jeff\" Sipek"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"31034","messageId":"204011cb0701070302y54837c5bp967e2cddd3fb655d@mail.gmail.com","threadId":"6266","inReplyTo":null,"subject":"Simple UI question...","fromName":"Chris Lee","fromEmail":"clee@kde.org","sentAt":"2007-01-07T11:02:59Z","receivedAt":"2007-01-07T11:02:59Z","isPatch":false,"sender":{"key":"clee@kde.org","avatar":"https://gravatar.com/avatar/c930bdc8cc6465094a5722188409ecb8955e0da2b188d7340137074b08f857e3?d=mp&s=160"},"body":"Hey guys,\n\nSo I'm trying to figure out the best way to pull out a checkout of the\nentire tree as of a given revision ID. I have a whole bunch of\nrevision IDs, and I'd like to know what the git equivalent of (say)\nthe following is:\n\nsvn co -r280600 file:///path/to/svn/repo\n\nFor the sake of argument, let's say that r280600 imported as\n07058310db903317faa300b93004a5a2e0fc2dcc into my git tree.\n\nHow do I get a pristine checkout in my working copy of the entire tree\nas the repository saw it at 07058310db903317faa300b93004a5a2e0fc2dcc?\n\nEric Anholt suggested 'git checkout -b temporary-branch-name\n$sha1sum'; davej suggested 'git-read-tree $sha1sum &&\ngit-checkout-index -a -f' but for some reason, neither of these\ncommands seems to do exactly as I expect. davej's method seems to work\nfor some revision IDs, but not for others, and the other method seems\nto work just about as well. (The problem I have seen is that, for some\nrevisions, the only files I get in the working copy are the files that\nwere changed in that commit; the rest of the files in the tree do not\nget checked out.)\n"},{"id":"31047","messageId":"20070107110648.GA20091@josefsipek.net","threadId":"6266","inReplyTo":"204011cb0701070302y54837c5bp967e2cddd3fb655d@mail.gmail.com","subject":"Re: Simple UI question...","fromName":"Josef \"Jeff\" Sipek","fromEmail":"jeffpc@josefsipek.net","sentAt":"2007-01-07T11:06:48Z","receivedAt":"2007-01-07T11:06:48Z","isPatch":false,"sender":{"key":"jeffpc@josefsipek.net","avatar":null},"body":"On Sun, Jan 07, 2007 at 03:02:59AM -0800, Chris Lee wrote:\n> Hey guys,\n> \n> So I'm trying to figure out the best way to pull out a checkout of the\n> entire tree as of a given revision ID. I have a whole bunch of\n> revision IDs, and I'd like to know what the git equivalent of (say)\n> the following is:\n> \n> svn co -r280600 file:///path/to/svn/repo\n> \n> For the sake of argument, let's say that r280600 imported as\n> 07058310db903317faa300b93004a5a2e0fc2dcc into my git tree.\n> \n> How do I get a pristine checkout in my working copy of the entire tree\n> as the repository saw it at 07058310db903317faa300b93004a5a2e0fc2dcc?\n\nI have great success with:\n\ngit-reset --hard $hash\n\nJeff.\n\n-- \n#endif /* NO LIFE */\n"},{"id":"31036","messageId":"20070107111305.GD10351@spearce.org","threadId":"6266","inReplyTo":"204011cb0701070302y54837c5bp967e2cddd3fb655d@mail.gmail.com","subject":"Re: Simple UI question...","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-01-07T11:13:05Z","receivedAt":"2007-01-07T11:13:05Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Chris Lee <clee@kde.org> wrote:\n> So I'm trying to figure out the best way to pull out a checkout of the\n> entire tree as of a given revision ID. I have a whole bunch of\n> revision IDs, and I'd like to know what the git equivalent of (say)\n> the following is:\n> \n> svn co -r280600 file:///path/to/svn/repo\n> \n> For the sake of argument, let's say that r280600 imported as\n> 07058310db903317faa300b93004a5a2e0fc2dcc into my git tree.\n> \n> How do I get a pristine checkout in my working copy of the entire tree\n> as the repository saw it at 07058310db903317faa300b93004a5a2e0fc2dcc?\n\nOne way is:\n\n  git archive \\\n    --format=tar \\\n    07058310db903317faa300b93004a5a2e0fc2dcc \\\n    | (mkdir ../export; cd ../export; tar xf -)\n\nWould give you a new directory tree which is not related to any\nGit repository, but which contains the exact set of files in 070583.\nBut that's probably not what you meant.\n \n> Eric Anholt suggested 'git checkout -b temporary-branch-name\n> $sha1sum';\n\nYes, that is usually the way you do this.  Unlike the archive trick\nabove the result will be in your current working directory and\nwill be associated with the current Git repository.  Further you\ncan modify this and commit changes if you need to.\n\n> davej suggested 'git-read-tree $sha1sum &&\n> git-checkout-index -a -f'\n\nThat's just cruel.  Its only part of the underlying operations that\ngit checkout is performing, and its trashing your current branch\nby making HEAD no longer match the index.  And its very low-level.\nAnd it doesn't really do a 2-way merge to fully update the working\ndirectory.  Not the best way for a user to perform this action.\nForget davej ever suggested this.\n\n> but for some reason, neither of these\n> commands seems to do exactly as I expect. davej's method seems to work\n> for some revision IDs, but not for others, and the other method seems\n> to work just about as well. (The problem I have seen is that, for some\n> revisions, the only files I get in the working copy are the files that\n> were changed in that commit; the rest of the files in the tree do not\n> get checked out.)\n\nThe problem is davej's method doesn't take into account what the\ncurrent working directory actually has stored in it.  It does not\ndelete any files which should not appear in $sha1sum.  It also\noverwrites more files than it needs to, as it overwrites everything\ninstead of just those files which actually differ between the\ncurrent working directory and $sha1sum.\n\nEric Anholt's version is the correct way to do it.  It is also very\nfast as it only has to modify the files which actually differed.\n\nIf Eric's version isn't always working then I'd have to suggest\nthat you exmaine the output of `git status` for switching to\nsome temporary branch based on $sha1sum.  Perhaps you have local\nmodifications which are carrying over in your working directory?\n\n-- \nShawn.\n"},{"id":"31041","messageId":"204011cb0701070321w18942a3w7fb4f7ecd26fc457@mail.gmail.com","threadId":"6266","inReplyTo":"20070107111305.GD10351@spearce.org","subject":"Re: Simple UI question...","fromName":"Chris Lee","fromEmail":"clee@kde.org","sentAt":"2007-01-07T11:21:56Z","receivedAt":"2007-01-07T11:21:56Z","isPatch":false,"sender":{"key":"clee@kde.org","avatar":"https://gravatar.com/avatar/c930bdc8cc6465094a5722188409ecb8955e0da2b188d7340137074b08f857e3?d=mp&s=160"},"body":"On 1/7/07, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Chris Lee <clee@kde.org> wrote:\n> > So I'm trying to figure out the best way to pull out a checkout of the\n> > entire tree as of a given revision ID. I have a whole bunch of\n> > revision IDs, and I'd like to know what the git equivalent of (say)\n> > the following is:\n> >\n> > svn co -r280600 file:///path/to/svn/repo\n> >\n> > For the sake of argument, let's say that r280600 imported as\n> > 07058310db903317faa300b93004a5a2e0fc2dcc into my git tree.\n> >\n> > How do I get a pristine checkout in my working copy of the entire tree\n> > as the repository saw it at 07058310db903317faa300b93004a5a2e0fc2dcc?\n>\n> One way is:\n>\n>   git archive \\\n>     --format=tar \\\n>     07058310db903317faa300b93004a5a2e0fc2dcc \\\n>     | (mkdir ../export; cd ../export; tar xf -)\n>\n> Would give you a new directory tree which is not related to any\n> Git repository, but which contains the exact set of files in 070583.\n> But that's probably not what you meant.\n>\n> > Eric Anholt suggested 'git checkout -b temporary-branch-name\n> > $sha1sum';\n>\n> Yes, that is usually the way you do this.  Unlike the archive trick\n> above the result will be in your current working directory and\n> will be associated with the current Git repository.  Further you\n> can modify this and commit changes if you need to.\n>\n> > davej suggested 'git-read-tree $sha1sum &&\n> > git-checkout-index -a -f'\n>\n> That's just cruel.  Its only part of the underlying operations that\n> git checkout is performing, and its trashing your current branch\n> by making HEAD no longer match the index.  And its very low-level.\n> And it doesn't really do a 2-way merge to fully update the working\n> directory.  Not the best way for a user to perform this action.\n> Forget davej ever suggested this.\n\nHeh. He's going to kill me for continuing to drag his name throught he\nmud. Anyway... :)\n\n> > but for some reason, neither of these\n> > commands seems to do exactly as I expect. davej's method seems to work\n> > for some revision IDs, but not for others, and the other method seems\n> > to work just about as well. (The problem I have seen is that, for some\n> > revisions, the only files I get in the working copy are the files that\n> > were changed in that commit; the rest of the files in the tree do not\n> > get checked out.)\n>\n> The problem is davej's method doesn't take into account what the\n> current working directory actually has stored in it.  It does not\n> delete any files which should not appear in $sha1sum.  It also\n> overwrites more files than it needs to, as it overwrites everything\n> instead of just those files which actually differ between the\n> current working directory and $sha1sum.\n\nWhat I've been doing is 'rm -rf *' from the working directory and\ntrying the commands out; I don't want any empty folders or anything.\n\n> Eric Anholt's version is the correct way to do it.  It is also very\n> fast as it only has to modify the files which actually differed.\n\nEric's shows the same problem - for some revision IDs, when I do a\ncheckout, I only get the files that were changed in that revision.\n\n> If Eric's version isn't always working then I'd have to suggest\n> that you exmaine the output of `git status` for switching to\n> some temporary branch based on $sha1sum.  Perhaps you have local\n> modifications which are carrying over in your working directory?\n\nI assume 'removing everything in the working tree' counts as \"local\nmodifications\"? :)\n"},{"id":"31043","messageId":"20070107112944.GF10351@spearce.org","threadId":"6266","inReplyTo":"204011cb0701070321w18942a3w7fb4f7ecd26fc457@mail.gmail.com","subject":"Re: Simple UI question...","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-01-07T11:29:45Z","receivedAt":"2007-01-07T11:29:45Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Chris Lee <clee@kde.org> wrote:\n> Eric's shows the same problem - for some revision IDs, when I do a\n> checkout, I only get the files that were changed in that revision.\n> \n> >If Eric's version isn't always working then I'd have to suggest\n> >that you exmaine the output of `git status` for switching to\n> >some temporary branch based on $sha1sum.  Perhaps you have local\n> >modifications which are carrying over in your working directory?\n> \n> I assume 'removing everything in the working tree' counts as \"local\n> modifications\"? :)\n\nYes!  That's what's going wrong.  Don't do \"rm -rf *\".  Let Git take\ncare of the empty directories for you.  If Git deletes all source\nfiles in that directory (as they don't belong in this version that\nyou are checking out) it will also delete the now empty directory.\n\nThe only time it fails is if you are on Windows and some process\nhas the directory busy.  :-)\n\n-- \nShawn.\n"},{"id":"31044","messageId":"7vodpb13bj.fsf@assigned-by-dhcp.cox.net","threadId":"6266","inReplyTo":"204011cb0701070302y54837c5bp967e2cddd3fb655d@mail.gmail.com","subject":"Re: Simple UI question...","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-07T11:30:56Z","receivedAt":"2007-01-07T11:30:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Chris Lee\" <clee@kde.org> writes:\n\n> Eric Anholt suggested 'git checkout -b temporary-branch-name\n> $sha1sum'; davej suggested 'git-read-tree $sha1sum &&\n> git-checkout-index -a -f' but for some reason, neither of these\n> commands seems to do exactly as I expect.\n\nThese two do vastly different things (but the latter is flawed\nand does _not_ do what it is trying to do).\n\n - If this checkout is just to look-see, and if you are on a\n   branch that is precious to you (say, you intend to keep\n   importing from svn or other repository onto that branch),\n   then you should use a temporary branch.  Eric's suggestion is\n   this approach -- but \"git checkout -b $branch $start\" is\n   about CREATING a new branch, so once you used the temporary\n   branch name, you cannot expect the same command line with\n   only different starting point to work.  In other words, I\n   suspect you saw \"it doesn't work\" because you did this:\n\n\t$ git checkout -b foo $commit1\n\t$ git checkout -b foo $commit2\n\n   and got an error message from the second one.\n\n - If you do not mind trashing the current branch, then \"git\n   reset --hard\" is what you want, and what you said was Dave's\n   suggestion is an incorrectly spelled version of old timer's\n   way to do what \"git reset --hard\" does by hand.\n\nAssuming that you do not want to trash your branch (and you\nusually don't), the correct sequence is first do:\n\n\t$ git checkout -b look-see\n\nThis creates a new branch \"look-see\" (the name does not matter\nas long as you do not have such a branch) from whatever branch\nyou happen to be on and switch to it.  After this, you will be\non the new \"look-see\" branch.  At which commit this branch\nstarts does not matter.\n\nThen, whichever commit you would want to check out and look at,\nyou would do:\n\n\t$ git reset --hard $commit\n \nThis \"trashes\" look-see branch by moving to that commit -- it\ntrashes in the sense that it makes the \"look-see\" branch forget\nabout all commits that comes after you resetted to, but you do\nnot care because this branch is temporary branch you created.\nOnce you are done looking at this commit, you can repeatedly say\n\"git reset --hard\" to move around to look at different commits.\n\nOnce you are done, you do not need to be on (nor need) look-see\nbranch, so get rid of it.\n\n\t$ git checkout master\n        $ git branch -D look-see\n\n> ... (The problem I have seen is that, for some\n> revisions, the only files I get in the working copy are the files that\n> were changed in that commit; the rest of the files in the tree do not\n> get checked out.)\n\nThis is because the low-level commands in the above example to\nmimick \"git reset --hard\" does is flawed.\n\nIf you are curious,...\n\nThe way \"git-reset --hard\" does it (it is just a shell script) is:\n\n\tgit-read-tree --reset -u $rev\n\nbut it does other things for safety.  Dave apparently learned\ngit long time before we only had plumbing (set of low-level\ncommands), so the suggestion did not use Porcelain (higher level\ncommands) \"git-reset\"; back then, the correct way to spell that\nwas:\n\n\tgit-read-tree $rev &&\n        git-checkout-index -f -q -u -a\n\nbut git-read-tree learned -u option and made the second command\nin this sequence unnecessary.\n\nIn general, you should not have to use git-checkout-index nor\ngit-read-tree yourself if you are working with today's git.\n"},{"id":"31045","messageId":"204011cb0701070338i5f8a8b4bw8b39050aeb192edb@mail.gmail.com","threadId":"6266","inReplyTo":"20070107112944.GF10351@spearce.org","subject":"Re: Simple UI question...","fromName":"Chris Lee","fromEmail":"clee@kde.org","sentAt":"2007-01-07T11:38:27Z","receivedAt":"2007-01-07T11:38:27Z","isPatch":false,"sender":{"key":"clee@kde.org","avatar":"https://gravatar.com/avatar/c930bdc8cc6465094a5722188409ecb8955e0da2b188d7340137074b08f857e3?d=mp&s=160"},"body":"On 1/7/07, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Chris Lee <clee@kde.org> wrote:\n> > I assume 'removing everything in the working tree' counts as \"local\n> > modifications\"? :)\n>\n> Yes!  That's what's going wrong.  Don't do \"rm -rf *\".  Let Git take\n> care of the empty directories for you.  If Git deletes all source\n> files in that directory (as they don't belong in this version that\n> you are checking out) it will also delete the now empty directory.\n>\n> The only time it fails is if you are on Windows and some process\n> has the directory busy.  :-)\n\nSo, if I were starting with an empty working directory, and I had just\nsynced over the .git folder from the place where I'm doing the actual\nimporting - how would I populate the working directory with a copy of\nthe contents of the tree from (say)\n07058310db903317faa300b93004a5a2e0fc2dcc ?\n"},{"id":"31046","messageId":"7vk5zz12va.fsf@assigned-by-dhcp.cox.net","threadId":"6266","inReplyTo":"204011cb0701070338i5f8a8b4bw8b39050aeb192edb@mail.gmail.com","subject":"Re: Simple UI question...","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-07T11:40:41Z","receivedAt":"2007-01-07T11:40:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Chris Lee\" <clee@kde.org> writes:\n\n> On 1/7/07, Shawn O. Pearce <spearce@spearce.org> wrote:\n>> Chris Lee <clee@kde.org> wrote:\n>> > I assume 'removing everything in the working tree' counts as \"local\n>> > modifications\"? :)\n>>\n>> Yes!  That's what's going wrong.  Don't do \"rm -rf *\".  Let Git take\n>> care of the empty directories for you.  If Git deletes all source\n>> files in that directory (as they don't belong in this version that\n>> you are checking out) it will also delete the now empty directory.\n>>\n>> The only time it fails is if you are on Windows and some process\n>> has the directory busy.  :-)\n>\n> So, if I were starting with an empty working directory, and I had just\n> synced over the .git folder from the place where I'm doing the actual\n> importing - how would I populate the working directory with a copy of\n> the contents of the tree from (say)\n> 07058310db903317faa300b93004a5a2e0fc2dcc ?\n\ngit reset --hard 070583\n"},{"id":"31048","messageId":"204011cb0701070350l4c736bcerbb236caf09a4d461@mail.gmail.com","threadId":"6266","inReplyTo":"7vk5zz12va.fsf@assigned-by-dhcp.cox.net","subject":"Re: Simple UI question...","fromName":"Chris Lee","fromEmail":"clee@kde.org","sentAt":"2007-01-07T11:50:52Z","receivedAt":"2007-01-07T11:50:52Z","isPatch":false,"sender":{"key":"clee@kde.org","avatar":"https://gravatar.com/avatar/c930bdc8cc6465094a5722188409ecb8955e0da2b188d7340137074b08f857e3?d=mp&s=160"},"body":"On 1/7/07, Junio C Hamano <junkio@cox.net> wrote:\n> \"Chris Lee\" <clee@kde.org> writes:\n> > So, if I were starting with an empty working directory, and I had just\n> > synced over the .git folder from the place where I'm doing the actual\n> > importing - how would I populate the working directory with a copy of\n> > the contents of the tree from (say)\n> > 07058310db903317faa300b93004a5a2e0fc2dcc ?\n>\n> git reset --hard 070583\n\nOkay, thanks :)\n\n(I don't really care about trying to do actual development on any of\nthe branches that I've imported - I mostly am interested in finding\nout some numbers on things like 'How much faster is git when rewinding\nthe directory tree to a given commit ID?' and related issues.)\n"}]}