{"thread":{"id":"6815","subject":"How to get rid of tracking branch?","startedAt":"2007-02-14T13:24:31Z","lastAt":"2007-02-14T17:04:42Z","messageCount":3,"participants":["Johannes Sixt","Andy Parkins","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"34522","messageId":"45D30D8F.50261DB0@eudaptics.com","threadId":"6815","inReplyTo":null,"subject":"How to get rid of tracking branch?","fromName":"Johannes Sixt","fromEmail":"j.sixt@eudaptics.com","sentAt":"2007-02-14T13:24:31Z","receivedAt":"2007-02-14T13:24:31Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Call me clueless, but how the heck do I get rid of a tracking remote\nbranch? I've cloned a repo locally, but in the clone I don't want to\ntrack all the topic branches of the origin. But git branch -d keeps\nsaying it doesn't find the remote branch:\n\n$ git version\ngit version 1.5.0\n$ git clone mingw-git/ mingw-git2\n[... all looks fine ...]\n$ cd mingw-git2/\n$ git branch -a\n* devel\n  origin/HEAD\n  origin/devel\n  origin/master\n  origin/origin\n  origin/repo-devel\n$ git branch -d origin/repo-devel\nerror: branch 'origin/repo-devel' not found.\n$ git branch -d remotes/origin/repo-devel\nerror: branch 'remotes/origin/repo-devel' not found.\n$ git branch -d heads/remotes/origin/repo-devel\nerror: branch 'heads/remotes/origin/repo-devel' not found.\n$ git branch -d refs/heads/remotes/origin/repo-devel\nerror: branch 'refs/heads/remotes/origin/repo-devel' not found.\n\n\nHow do I delete remote branches? Do I have to\n\n rm .git/refs/heads/remotes/origin/repo-devel\n\n(I know I have to update the config, too, so that the next pull doesn't\ndraw the branch in again, but I haven't done that at this point.)\n\n-- Hannes\n"},{"id":"34523","messageId":"200702141335.41165.andyparkins@gmail.com","threadId":"6815","inReplyTo":"45D30D8F.50261DB0@eudaptics.com","subject":"Re: How to get rid of tracking branch?","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-02-14T13:35:37Z","receivedAt":"2007-02-14T13:35:37Z","isPatch":false,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Wednesday 2007 February 14 13:24, Johannes Sixt wrote:\n> Call me clueless, but how the heck do I get rid of a tracking remote\n> branch? I've cloned a repo locally, but in the clone I don't want to\n> track all the topic branches of the origin. But git branch -d keeps\n> saying it doesn't find the remote branch:\n\n $ git branch -r -d origin/repo-devel\n\nI suffered the same thing a while ago :-)\n\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIEE\nandyparkins@gmail.com\n"},{"id":"34567","messageId":"7vsld8r7px.fsf@assigned-by-dhcp.cox.net","threadId":"6815","inReplyTo":"200702141335.41165.andyparkins@gmail.com","subject":"Re: How to get rid of tracking branch?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-14T17:04:42Z","receivedAt":"2007-02-14T17:04:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andy Parkins <andyparkins@gmail.com> writes:\n\n> On Wednesday 2007 February 14 13:24, Johannes Sixt wrote:\n>> Call me clueless, but how the heck do I get rid of a tracking remote\n>> branch? I've cloned a repo locally, but in the clone I don't want to\n>> track all the topic branches of the origin. But git branch -d keeps\n>> saying it doesn't find the remote branch:\n>\n>  $ git branch -r -d origin/repo-devel\n>\n> I suffered the same thing a while ago :-)\n\nI think you would also need to futz with remote.origin.fetch\nthat says \"track all branches from remote\", or your next pull\nwill re-create them.\n\nYou probably have\n\n\t[remote \"origin\"]\n        \turl = ...\n                fetch = +refs/heads/*:refs/remotes/origin/*\n\t[branch \"master\"]\n        \tremote = origin\n                merge = refs/heads/master\n\nYou would change it to list the branch you want to track\nexplicitly:\n\n\t[remote \"origin\"]\n        \turl = ...\n                fetch = refs/heads/master:refs/remotes/origin/master\n\nHowever, this has a subtle side effect.  If you create a new\nbranch, say \"test\", running \"git pull\" while on \"test\" will\nmerge \"master\".  This is not wrong per-se (it has been the\ntraditional git-pull behaviour and if you want to use the remote\nbranch that is not the one first listed on remote.origin.fetch\nline, you can set up branch.test.merge yourself), but it may\nsurprise you because it is different when you use the globbing\nrefspec on the remote.origin.fetch line.\n\nSo if you want to track only two remote branches, say 'master'\nand 'dev', and if you want to also have your own 'master' and\n'dev' that builds on them, you would have something like:\n\n\t[remote \"origin\"]\n        \turl = ...\n                fetch = refs/heads/master:refs/remotes/origin/master\n                fetch = refs/heads/dev:refs/remotes/origin/dev\n\t[branch \"master\"]\n        \tremote = origin\n                merge = refs/heads/master\n\t[branch \"dev\"]\n        \tremote = origin\n                merge = refs/heads/dev\n\nThen while on 'master', \"git pull\" will fetch from origin and\nmerge their 'master' in, and while on 'dev' \"git pull\" will\nmerge their 'dev' in.\n"}]}