2

Possible duplicate: Getting existing git branches to track remote branches

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.

Community
  • 1
  • 1
Favourite Onwuemene
  • 4,247
  • 8
  • 28
  • 46

1 Answers1

5

There are many solutions to this task.

1. Manual update

You can open the .git/config file and add the definition of your branch:

[branch "myfeature"]
   remote = origin
   merge = refs/heads/myfeature

Now your existing branch myfeature will track the remote branch refs/heads/myfeature from origin.

2. Using branch command

Another way is to use the set-upstream of the branch command:

git branch --set-upstream <your-branch> origin/<remote-branch>

It will update your .git/config file.

Sergey K.
  • 24,894
  • 13
  • 106
  • 174