On Wed, 31 Dec 2008, Zorba wrote: > Ok, now I'm following you, cos I just "broke" checkout again by deleting > files from working dirs before running it. > > git-checkout takes into account the state of the working tree in the commit > it is run FROM, as well as the commit it is checking out. > > It relies on the working tree being in synch with the commit it is run from. > If I delete files, I screw around with this initial state. > Files that git-checkout is relying on to be there are not copied in by it, > so if I've deleted (or modified) those files, hard luck. It's not relying on these files to be there; it's actually aware that they're not there. It thinks that any modifications you've made might be important work, and carefully preserves it. Actually, it should be telling you the changes that it's carrying over with lines like: D ABC.txt (which indicated that you've deleted ABC.txt, and it's keeping that modification) > I remember s/o saying git minimizes file I/O, and this whats happening here. > > It puts a big demand on the user, to keep their index & working dir in synch > with whats in the commit. The user is hopefully not going to make a lot of random undesired changes in general. It's hard to get much done that way. If you have made changes, you can use "git checkout ." to get the versions back from the index, or "git checkout HEAD ." to get them back from the commit. > Ah, > > $ git checkout . > > will restore the state of the working dir to be in synch with the CURRENT > commit, so it will be safe to checkout other branches > > BINGO !! > what I need to do is run the sequence > > $ git checkout . // tidy up current commit > $ git checkout <version> // roll back > > n'est pas ? Either that, or: $ git checkout <version> $ git checkout . (it doesn't matter whether you get rid of the local modifications and deletions before switching, or switch first, and then get rid of any remaining local modifications and deletions) You may also want: $ git clean To get rid of untracked files you may have around (use "git clean -x" if you also want to get rid of files you've told git to ignore). Incidentally, if your goal is to give someone a copy of the state as of a particular version, you can use: $ git archive --format=zip <commit> > version.zip This doesn't involve your working directory at all, and just generates a zip file out of the history. I find that this means I rarely actually care about having a working directory that's free of random junk. -Daniel *This .sig left intentionally blank* -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html