{"thread":{"id":"23265","subject":"git push refspec to specify tracking branch","startedAt":"2010-03-31T01:06:45Z","lastAt":"2010-03-31T03:24:50Z","messageCount":3,"participants":["Kevin Ballard","Avery Pennarun"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"138244","messageId":"13A69FD9-234A-4E2A-B83F-096DE304FA16@sb.org","threadId":"23265","inReplyTo":null,"subject":"git push refspec to specify tracking branch","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-03-31T01:06:45Z","receivedAt":"2010-03-31T01:06:45Z","isPatch":false,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"Is there any way in a refspec to specify the tracking branch corresponding to a local branch? Specifically, I want to be able to write some variant of `git push origin +foo` and have it push foo to its tracking branch. I can't find any way to do that according to the current documentation.\n\n-Kevin Ballard"},{"id":"138245","messageId":"32541b131003301819x2cab23ffu84b65a0b4c553229@mail.gmail.com","threadId":"23265","inReplyTo":"13A69FD9-234A-4E2A-B83F-096DE304FA16@sb.org","subject":"Re: git push refspec to specify tracking branch","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2010-03-31T01:19:41Z","receivedAt":"2010-03-31T01:19:41Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Tue, Mar 30, 2010 at 9:06 PM, Kevin Ballard <kevin@sb.org> wrote:\n> Is there any way in a refspec to specify the tracking branch\n> corresponding to a local branch? Specifically, I want to be able to\n> write some variant of `git push origin +foo` and have it push foo to\n> its tracking branch. I can't find any way to do that according to\n> the current documentation.\n\nThis is probably a stupid suggestion, but since you're only likely to\nhave a single local branch corresponding to a particular remote\nbranch, the easiest answer is to rename your local branch to have the\nsame name :)\n\nOtherwise, what you probably want is:\n\n   git push origin localbranchname:remotebranchname\n\nYou can also delete a remote branch:\n\n   git push origin :remotebranchname\n\nHave fun,\n\nAvery\n"},{"id":"138255","messageId":"32541b131003302024n42994e3nddab7544c24f93bd@mail.gmail.com","threadId":"23265","inReplyTo":"5D7B2F13-760B-4EBE-93A4-06B9CDDC3976@sb.org","subject":"Re: git push refspec to specify tracking branch","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2010-03-31T03:24:50Z","receivedAt":"2010-03-31T03:24:50Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Tue, Mar 30, 2010 at 10:24 PM, Kevin Ballard <kevin@sb.org> wrote:\n> On Mar 30, 2010, at 6:19 PM, Avery Pennarun wrote:\n>> git push origin localbranchname:remotebranchname\n>\n> Yes that works, but it's annoying to type out every time, especially when my\n> branch has a long name and I don't want to risk typos. Even worse, the\n> tab-completion in bash uses `git ls-remote` to complete the remote part of\n> refspecs, so it's even slower to type \"foo:kba<tab>\" than it is to type\n> \"foo:kballard/foo\".\n\nYou might consider creating a separate 'remote' entry then in your\n.git/config.  You should be able to reconfigure the refspec on that\none to use a particular branch name instead of a wildcard.  It's not\nexactly pretty, but laziness will be laziness.\n\nA similar option would be to just make a shell alias and be done with it:\n\nsavebranch()\n{\n    git push origin $1:kballard-$1\n}\n\nHave fun,\n\nAvery\n"}]}