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.

1
  • You can push your branch into remote branch with -u option Commented Oct 5, 2012 at 9:46

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.