# Pushing a new branch to a remote and tracking it

3 messages from 2010-07-27 to 2010-07-28. Participants: Bradley Wagner, Andreas Schwab.
Thread: https://gitlist.dev/t/24543

## Bradley Wagner, 2010-07-27 22:12

Subject: Pushing a new branch to a remote and tracking it
Message-ID: <AANLkTikxmhndNqGDpwfBm41OuaPvnB=2xqp6gkYOTQiF@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikxmhndNqGDpwfBm41OuaPvnB%3D2xqp6gkYOTQiF%40mail.gmail.com

```
Is there a more elegant way to: 1) create a branch, 2) push it to a
remote and 3) continue to track it.

I noticed that:

git branch <branchname> HEAD
git checkout <branchname>
git push origin <branchname>

does not link the local branch to the remote.

I've seen other people do:

git push origin origin:refs/heads/<branchname>
git fetch origin
git branch -r (verify that the branch is there)
git checkout <branchname> -b origin/<branchname>

but it seems kind of the reverse of what I would expect to do. I know
I could also do the first thing and then delete/re-checkout the branch
with tracking.

```

## Andreas Schwab, 2010-07-27 22:35

Subject: Re: Pushing a new branch to a remote and tracking it
Message-ID: <m26300o8nm.fsf@igel.home>
URL: https://gitlist.dev/e/m26300o8nm.fsf%40igel.home
In-Reply-To: <AANLkTikxmhndNqGDpwfBm41OuaPvnB=2xqp6gkYOTQiF@mail.gmail.com>

```
Bradley Wagner <bradley.wagner@hannonhill.com> writes:

> Is there a more elegant way to: 1) create a branch, 2) push it to a
> remote and 3) continue to track it.

git push --set-upstream (since v1.7.0)

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```

## Bradley Wagner, 2010-07-28 01:20

Subject: Re: Pushing a new branch to a remote and tracking it
Message-ID: <AANLkTikatSEN1TpZ3SrEVcSOUo+tg=LpUc9d76o3dPXU@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikatSEN1TpZ3SrEVcSOUo%2Btg%3DLpUc9d76o3dPXU%40mail.gmail.com
In-Reply-To: <m26300o8nm.fsf@igel.home>

```
On Tue, Jul 27, 2010 at 6:35 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Bradley Wagner <bradley.wagner@hannonhill.com> writes:
>
>> Is there a more elegant way to: 1) create a branch, 2) push it to a
>> remote and 3) continue to track it.
>
> git push --set-upstream (since v1.7.0)

Thanks! That's exactly what I was looking for.

```
