git push refspec to specify tracking branch

Previous thread: [RFC PATCH 0/2] gitk --color-words by Thomas Rast on Tuesday, March 30, 2010 - 5:52 pm. (11 messages)

Next thread: [PATCH] Documentation: clarify grammar by Yawar Amin on Tuesday, March 30, 2010 - 7:28 pm. (5 messages)
From: Kevin Ballard
Date: Tuesday, March 30, 2010 - 6:06 pm

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.

-Kevin Ballard--

From: Avery Pennarun
Date: Tuesday, March 30, 2010 - 6:19 pm

This is probably a stupid suggestion, but since you're only likely to
have a single local branch corresponding to a particular remote
branch, the easiest answer is to rename your local branch to have the
same name :)

Otherwise, what you probably want is:

   git push origin localbranchname:remotebranchname

You can also delete a remote branch:

   git push origin :remotebranchname

Have fun,

Avery
--

From: Avery Pennarun
Date: Tuesday, March 30, 2010 - 8:24 pm

You might consider creating a separate 'remote' entry then in your
.git/config.  You should be able to reconfigure the refspec on that
one to use a particular branch name instead of a wildcard.  It's not
exactly pretty, but laziness will be laziness.

A similar option would be to just make a shell alias and be done with it:

savebranch()
{
    git push origin $1:kballard-$1
}

Have fun,

Avery
--

Previous thread: [RFC PATCH 0/2] gitk --color-words by Thomas Rast on Tuesday, March 30, 2010 - 5:52 pm. (11 messages)

Next thread: [PATCH] Documentation: clarify grammar by Yawar Amin on Tuesday, March 30, 2010 - 7:28 pm. (5 messages)