# git push refspec to specify tracking branch

3 messages from 2010-03-31 to 2010-03-31. Participants: Kevin Ballard, Avery Pennarun.
Thread: https://gitlist.dev/t/23265

## Kevin Ballard, 2010-03-31 01:06

Subject: git push refspec to specify tracking branch
Message-ID: <13A69FD9-234A-4E2A-B83F-096DE304FA16@sb.org>
URL: https://gitlist.dev/e/13A69FD9-234A-4E2A-B83F-096DE304FA16%40sb.org

```
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
```

## Avery Pennarun, 2010-03-31 01:19

Subject: Re: git push refspec to specify tracking branch
Message-ID: <32541b131003301819x2cab23ffu84b65a0b4c553229@mail.gmail.com>
URL: https://gitlist.dev/e/32541b131003301819x2cab23ffu84b65a0b4c553229%40mail.gmail.com
In-Reply-To: <13A69FD9-234A-4E2A-B83F-096DE304FA16@sb.org>

```
On Tue, Mar 30, 2010 at 9:06 PM, Kevin Ballard <kevin@sb.org> wrote:
> 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.

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

```

## Avery Pennarun, 2010-03-31 03:24

Subject: Re: git push refspec to specify tracking branch
Message-ID: <32541b131003302024n42994e3nddab7544c24f93bd@mail.gmail.com>
URL: https://gitlist.dev/e/32541b131003302024n42994e3nddab7544c24f93bd%40mail.gmail.com
In-Reply-To: <5D7B2F13-760B-4EBE-93A4-06B9CDDC3976@sb.org>

```
On Tue, Mar 30, 2010 at 10:24 PM, Kevin Ballard <kevin@sb.org> wrote:
> On Mar 30, 2010, at 6:19 PM, Avery Pennarun wrote:
>> git push origin localbranchname:remotebranchname
>
> Yes that works, but it's annoying to type out every time, especially when my
> branch has a long name and I don't want to risk typos. Even worse, the
> tab-completion in bash uses `git ls-remote` to complete the remote part of
> refspecs, so it's even slower to type "foo:kba<tab>" than it is to type
> "foo:kballard/foo".

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

```
