I know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch?
I know I can just edit the .git/config
file, but it seems there should be an easier way.
I know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch?
I know I can just edit the .git/config
file, but it seems there should be an easier way.
Editing
.git/config
is probably the easiest and fastest way. That's what the Git commands for handling remote branches are doing, anyway.If you don't want to muck with the file by hand (and it's not that hard to do), you can always use
git config
to do it...but again, that's just going to edit the.git/config
file, anyway.There are, of course, ways to automatically track a remote branch when using
git checkout
(by passing the--track
flag, for example), but these commands work with new branches, not existing ones.or simply by :
switch to the branch if you are not in it already:
run
and you ready to :
You can alawys take a look at the config file to see what is tracking what by running:
It's also nice to know this, it shows which branches are tracked and which ones are not. :
You can do the following (assuming you are checked out on master and want to push to a remote branch master):
Set up the 'remote' if you don't have it already
Now configure master to know to track:
And push:
Use '--track' Option
After a
git pull
:git checkout --track <remote-branch-name>
Or:
git fetch && git checkout <branch-name>
In very short
This will make your
yourLocalBranchName
track the remote branch calleddevelop
.This would work too