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.
branchgitgit-branch
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.
Best Answer
Given a branch
foo
and a remoteupstream
:As of Git 1.8.0:
Or, if local branch
foo
is not the current branch:Or, if you like to type longer commands, these are equivalent to the above two:
As of Git 1.7.0 (before 1.8.0):
Notes:
foo
to track remote branchfoo
from remoteupstream
.git fetch upstream
beforehand.See also: Why do I need to do `--set-upstream` all the time?