{"thread":{"id":"46212","subject":"Git Strange behaviour with remote deleted branch","startedAt":"2017-06-19T21:33:12Z","lastAt":"2017-06-20T16:20:15Z","messageCount":3,"participants":["Reda Lyazidi","Paul Smith","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"322614","messageId":"39331ce5-dbf9-170e-e550-784db10b966f@gmail.com","threadId":"46212","inReplyTo":null,"subject":"Git Strange behaviour with remote deleted branch","fromName":"Reda Lyazidi","fromEmail":"reda.lyazidiprojet@gmail.com","sentAt":"2017-06-19T21:33:04Z","receivedAt":"2017-06-19T21:33:12Z","isPatch":false,"sender":{"key":"reda.lyazidiprojet@gmail.com","avatar":null},"body":"Hello,\n\nwith git I noticed when I removed a remote branch with git push origin \n--delete <the branch>\nin my clone when I used git branch -a I don't the deleted branch\nbut my colleagues still see it.\n\nI tried with two clones in my PC, with the first one delete branch and \nthe other still sees it\ndespite git pull .\n\nI use git version 2.9.4\n\nKind regards.\n\n"},{"id":"322625","messageId":"1497908782.6463.8.camel@mad-scientist.net","threadId":"46212","inReplyTo":"39331ce5-dbf9-170e-e550-784db10b966f@gmail.com","subject":"Re: Git Strange behaviour with remote deleted branch","fromName":"Paul Smith","fromEmail":"paul@mad-scientist.net","sentAt":"2017-06-19T21:46:22Z","receivedAt":"2017-06-19T22:14:31Z","isPatch":false,"sender":{"key":"paul@mad-scientist.net","avatar":"https://avatars.githubusercontent.com/u/109636?v=4"},"body":"On Mon, 2017-06-19 at 23:33 +0200, Reda Lyazidi wrote:\n> with git I noticed when I removed a remote branch with git push origin \n> --delete <the branch>\n> in my clone when I used git branch -a I don't the deleted branch\n> but my colleagues still see it.\n> \n> I tried with two clones in my PC, with the first one delete branch and \n> the other still sees it\n> despite git pull .\n\nNormally Git will not remove a remote's branch refs on a fetch (or\npull) operation.  This is a safety measure, since you might still have\na use for that branch (for example to run diff against or similar).\n\nIn order to remove branches that have been deleted in your remote, you\nmust use the --prune (or -p) option to git fetch or git pull:\n\n  git pull -p\n\nwill get rid of them.\n\n"},{"id":"322741","messageId":"20170620162010.mm4qi6lgwu7sdmhd@sigill.intra.peff.net","threadId":"46212","inReplyTo":"1497908782.6463.8.camel@mad-scientist.net","subject":"Re: Git Strange behaviour with remote deleted branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-06-20T16:20:10Z","receivedAt":"2017-06-20T16:20:15Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 19, 2017 at 05:46:22PM -0400, Paul Smith wrote:\n\n> On Mon, 2017-06-19 at 23:33 +0200, Reda Lyazidi wrote:\n> > with git I noticed when I removed a remote branch with git push origin \n> > --delete <the branch>\n> > in my clone when I used git branch -a I don't the deleted branch\n> > but my colleagues still see it.\n> > \n> > I tried with two clones in my PC, with the first one delete branch and \n> > the other still sees it\n> > despite git pull .\n> \n> Normally Git will not remove a remote's branch refs on a fetch (or\n> pull) operation.  This is a safety measure, since you might still have\n> a use for that branch (for example to run diff against or similar).\n> \n> In order to remove branches that have been deleted in your remote, you\n> must use the --prune (or -p) option to git fetch or git pull:\n> \n>   git pull -p\n> \n> will get rid of them.\n\nThis is exactly correct. One further question, though, is \"why does\ngit-push remove the branch?\".\n\nIt makes sense that in general it tries to update the tracking branches\nto match what we know we just sent to the other side. It's just\nanticipating the next \"git fetch\".  But it is a little funny that it\ntreats deletion differently than fetch would.\n\nI don't recall that behavior being consciously decided. I could see an\nargument for the current behavior: the danger is less because the branch\ndidn't just \"go away\" upstream, it was something the user in the local\nrepository did. But I could also see an argument for the other: the\npoint is to anticipate the next fetch, and it should behave exactly like\nfetch.\n\nI don't have a strong opinion either way.\n\nI do hope that one day we would turn on \"fetch --prune\" by default, but\nI'd prefer to see better safety for recovering deleted refs first (e.g.,\nif we retained the reflog and you could access origin/deleted@{1}).\n\n-Peff\n"}]}