Thursday 20 July 2017

Make local Git branch track a remote branch

Problem:

How do I get a local git branch to track a remote branch?

Solution:

The following examples assume a branch "thebranch" and a remote "myremote". They also assume you are using git in the command line.

For Git 1.8.0 and later:

If you've already checked out "thebranch" on your local, then:

git branch -u myremote/thebranch

If you haven't checked out "thebranch" on your local, then:

git branch -u myremote/thebranch thebranch

For Git 1.7.0 until 1.7.12.4, if you've checked out "thebranch" on your local, then:

git branch --set-upstream-to=myremote/thebranch

If you haven't checked out "thebranch" on your local, then:

git branch --set-upstream-to=myremote/thebranch thebranch

References:

No comments:

Post a Comment