{"thread":{"id":"40137","subject":"Why does 'git branch -d' act differntly after clone?","startedAt":"2015-08-20T12:10:37Z","lastAt":"2015-08-20T15:49:24Z","messageCount":2,"participants":["Konstantin Hollerith","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"268359","messageId":"CALwJaCzYgDKdcT7H7=5x0fnNRv4MsrtjJoHJcB9rJyh3dU--xQ@mail.gmail.com","threadId":"40137","inReplyTo":null,"subject":"Why does 'git branch -d' act differntly after clone?","fromName":"Konstantin Hollerith","fromEmail":"khollerith@gmail.com","sentAt":"2015-08-20T12:10:37Z","receivedAt":"2015-08-20T12:10:37Z","isPatch":false,"sender":{"key":"khollerith@gmail.com","avatar":null},"body":"Hi,\n\nI created a simple repository.\nIf i create a new branch from master and commit some changes and\nthen delete it with\n\n    git branch -d neuerTestBranch\n\nI'll get a error:\n\n    error: The branch 'neuerTestBranch' is not fully merged.\n\nI like that error, it reminds me, that i forgot to merge.\nHowever, if i don't delete this branch and clone the Repository somewhere\nelse, i don't get the error anymore. When i delete the branch now, i get\nthis message:\n\n    warning: deleting branch 'neuerTestBranch' that has been merged to\n    'refs/remotes/origin/neuerTestBranch', but not yet merged to HEAD.\n\nAnd the Branch is deleted right away.\n\nWhy does git branch -d acts differently after a clone?\nIs this behavior maybe a Bug?\nIs it possible to force a behavior like the first in cloned repositories,\ntoo?\n\nI use 'git version 2.5.0.windows.1'.\n\nCheers,\nKonstantin\n"},{"id":"268370","messageId":"xmqqa8tm7yez.fsf@gitster.dls.corp.google.com","threadId":"40137","inReplyTo":"CALwJaCzYgDKdcT7H7=5x0fnNRv4MsrtjJoHJcB9rJyh3dU--xQ@mail.gmail.com","subject":"Re: Why does 'git branch -d' act differntly after clone?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-08-20T15:49:24Z","receivedAt":"2015-08-20T15:49:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Konstantin Hollerith <khollerith@gmail.com> writes:\n\n> Why does git branch -d acts differently after a clone?\n\nIn the former case, that branch is the only thing that knows about\nthe commits near the tip of it.  Immediately after you clone that\nrepository, you have a copy of that branch as a remote-tracking\nbranch for origin/neuerTestBranch.  You didn't say how you got a\nlocal copy of it in there, but I'd imagine that in the clone you did\nsomething like:\n\n    $ git checkout neuerTestBranch\n\nwhich is a short-hand for\n\n    $ git checkout -b neuerTestBranch origin/neuerTestBranch\n\nand then went back to a branch other than that branch when you asked\nthe branch to be removed, e.g.\n\n    $ git checkout master\n    $ git branch -d neuerTestBranch\n\nwithout building any further history on neuerTestBranch.\n\nNow, your local neuerTestBranch is a mere unmodified copy of the\nremote-tracking branch origin/neuerTestBranch; the commits on the\nformer will not become unreachable if you remove neuerTestBranch,\nbecause they are all reachable via origin/neuerTestBranch.  And that\nis why the deletion of it has less severe potential of information\nlossage, compared to the original case where you attempt to remove\nthe only copy.\n"}]}