{"thread":{"id":"32099","subject":"checkout from neighbour branch undeletes a path?","startedAt":"2012-11-13T15:23:41Z","lastAt":"2012-11-13T23:41:10Z","messageCount":4,"participants":["Peter Vereshagin","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"203090","messageId":"20121113152341.GC6561@external.screwed.box","threadId":"32099","inReplyTo":null,"subject":"checkout from neighbour branch undeletes a path?","fromName":"Peter Vereshagin","fromEmail":"peter@vereshagin.org","sentAt":"2012-11-13T15:23:41Z","receivedAt":"2012-11-13T15:23:41Z","isPatch":false,"sender":{"key":"peter@vereshagin.org","avatar":"https://gravatar.com/avatar/27a92b8c80743df8621433ca040657c4ac37a78497228d04f703e70731c5f30b?d=mp&s=160"},"body":"Hello.\n\nAm wondering if 'checkout branch path' undeletes the files? For the example\nbelow I'd like the 'file00.txt' to be deleted and never checked out from the\nprevious branch... How can I do that?\n\n  $ git init                                                                                             \n  Initialized empty Git repository in /tmp/repo00/.git/\n  $ mkdir pathdir\n  $ echo test00 > pathdir/file00.txt\n  $ git add pathdir\n  $ git commit -am 'added file00.txt'\n  [master (root-commit) d4f7c70] added file00.txt\n   1 files changed, 1 insertions(+), 0 deletions(-)\n   create mode 100644 pathdir/file00.txt\n  $ git branch -m master branch00\n  $ git branch branch01\n  $ rm pathdir/file00.txt\n  $ echo test01 > pathdir/file01.txt\n  $ git add pathdir\n  $ git status\n  $ git commit -am 'added file01.txt; removed file00.txt'\n  [branch00 c3e78ff] added file01.txt; removed file00.txt\n   2 files changed, 1 insertions(+), 1 deletions(-)\n   delete mode 100644 pathdir/file00.txt\n   create mode 100644 pathdir/file01.txt\n  $ git checkout branch01\n  Switched to branch 'branch01'\n  $ rm -r pathdir\n  $ git checkout branch00 pathdir\n  $ find pathdir/\n  pathdir/\n  pathdir/file00.txt\n  pathdir/file01.txt\n  $\n\nI know about 'merge' and it's not the what I need:  to import only the\nparticular subdirectory from the previous branch.\n\nThank you.\n\n--\nPeter Vereshagin <peter@vereshagin.org> (http://vereshagin.org) pgp: A0E26627\n"},{"id":"203105","messageId":"7v8va5fo7g.fsf@alter.siamese.dyndns.org","threadId":"32099","inReplyTo":"20121113152341.GC6561@external.screwed.box","subject":"Re: checkout from neighbour branch undeletes a path?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-13T16:43:31Z","receivedAt":"2012-11-13T16:43:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Vereshagin <peter@vereshagin.org> writes:\n\n> Am wondering if 'checkout branch path' undeletes the files?\n\n\"git checkout branch path\" (by the way, \"branch\" does not have to be\na branch name; any commit object name would do, like \"git checkout\nHEAD^^ hello.c\") is a way to check out named path(s) out of the\nnamed commit.\n\nIf the commit \"branch\" has \"path\" in it, its contents are checked\nout to \"path\" in your current working tree (and the entry in the\nindex updated to match it).\n\nIf you happen to have removed \"path\" in your current working tree\nbefore running that command, it might look as if there is some\nundelete going on, but that is a wrong way to look at things.  The\nversion of \"path\" in the \"branch\" may or may not be similar to what\nyou have removed earlier.\n"},{"id":"203128","messageId":"20121113183400.GE6561@external.screwed.box","threadId":"32099","inReplyTo":"7v8va5fo7g.fsf@alter.siamese.dyndns.org","subject":"Re: checkout from neighbour branch undeletes a path?","fromName":"Peter Vereshagin","fromEmail":"peter@vereshagin.org","sentAt":"2012-11-13T18:34:00Z","receivedAt":"2012-11-13T18:34:00Z","isPatch":false,"sender":{"key":"peter@vereshagin.org","avatar":"https://gravatar.com/avatar/27a92b8c80743df8621433ca040657c4ac37a78497228d04f703e70731c5f30b?d=mp&s=160"},"body":"Hello.\n\n2012/11/13 08:43:31 -0800 Junio C Hamano <gitster@pobox.com> => To Peter Vereshagin :\nJCH> Peter Vereshagin <peter@vereshagin.org> writes:\nJCH> \nJCH> > Am wondering if 'checkout branch path' undeletes the files?\nJCH> \nJCH> \"git checkout branch path\" (by the way, \"branch\" does not have to be\nJCH> a branch name; any commit object name would do, like \"git checkout\nJCH> HEAD^^ hello.c\") is a way to check out named path(s) out of the\nJCH> named commit.\nJCH> \nJCH> If the commit \"branch\" has \"path\" in it, its contents are checked\nJCH> out to \"path\" in your current working tree (and the entry in the\nJCH> index updated to match it).\nJCH> \nJCH> If you happen to have removed \"path\" in your current working tree\nJCH> before running that command, it might look as if there is some\nJCH> undelete going on, but that is a wrong way to look at things.  The\nJCH> version of \"path\" in the \"branch\" may or may not be similar to what\nJCH> you have removed earlier.\nJCH> \n\n\nHello.\n\nI solved my problem by mean of 'git rm' instead of 'rm'.\n\nI knew what you said here. Shortly, the difference for my case was:\n\n - I check out the pathdir from the commit in which the pathdir/file00 was\n   already removed.\n\n - The current branch 'branch01' has no idea the file00 was removed. But I\n   removed file00 and this is what 'branch01' assumes when I commit n ext time.\n\nBut git assumes I need 'file00' although it doesn't exist in the commit I\ncheckout path from. It doesn't exist by itself before I checkout that path\nneither.\n\nHow can I know which one of the 'file00' versions is being checked out: the one\nthat did exist in the 'branch00' (the where I checkout path from) before I\nremoved it or the one existing in HEAD but not in the work-tree? And why this\nand not that?\n\nIf it is the one that exists in a current branch but was deleted from trhe\nwork-tree [d4f7c70] than why it is being checked out not from the commit\nsupplied as an argument to git?\n\nIf it is the one that existed [c3e78ff] before the commit I checkout path from\nthan why it is being checked out while it doesn't exist in that commit already?\n\nThank you.\n\n--\nPeter Vereshagin <peter@vereshagin.org> (http://vereshagin.org) pgp: A0E26627 \n"},{"id":"203159","messageId":"7vbof1cbqh.fsf@alter.siamese.dyndns.org","threadId":"32099","inReplyTo":"20121113152341.GC6561@external.screwed.box","subject":"Re: checkout from neighbour branch undeletes a path?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-13T23:41:10Z","receivedAt":"2012-11-13T23:41:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Vereshagin <peter@vereshagin.org> writes:\n\n>   $ rm -r pathdir\n>   $ git checkout branch00 pathdir\n>   $ find pathdir/\n>   pathdir/\n>   pathdir/file00.txt\n>   pathdir/file01.txt\n>   $\n\nHasn't this been fixed at 0a1283b (checkout $tree $path: do not\nclobber local changes in $path not in $tree, 2011-09-30)?\n\nAre you using 1.7.7.1 or newer?  If not, please upgrade.\n"}]}