It may happen that you create a local branch and forget to make it track a remote branch. We can make up for this by using the –set-upstream-to option of the git branch command. Say we are currently on branch issue123 and we want to make this branch track origin‘s issue123 branch.
For Git versions >=1.8
git fetch # may be necessary in order to get origin/issue123 git branch --set-upstream-to=origin/issue123 issue123
For Git versions <= 1.7
Mind the switched order of arguments. This command will also work in later Git versions:
git branch --set-upstream issue123 origin/issue123
- stackoverflow offers additional solutions for this task