threads / discuss / 24543

Pushing a new branch to a remote and tracking it

Subject: Pushing a new branch to a remote and tracking it

## tl;dr

3 messages between Jul 27, 2010 and Jul 28, 2010.

replies: 2people: 2as markdown or json

Bradley Wagner· Jul 27, 2010, 22:12 UTC · lore

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· Jul 27, 2010, 22:35 UTC · re: Bradley Wagner · lore

Re: Pushing a new branch to a remote and tracking it

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· Jul 28, 2010, 01:20 UTC · re: Andreas Schwab · lore

Re: Pushing a new branch to a remote and tracking it

On Tue, Jul 27, 2010 at 6:35 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
Show 6 quoted lines
> 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.

← back to recent threads