Git - Change tracking configuration of branches

3.6k Views Asked by At

I have the following branches (local and remote):

origin/master
origin/alter
origin/alter_old
master
alter
alter_old

If I do git branch -vv I get:

master     6aec3b5 [origin/master] blam
alter      8c32a03 blaa1
alter_old  1669af7 [origin/alter: ahead N, behind M] blaa2

I want alter to track origin/alter and alter_old to track origin/alter_old. How can I do it? I tried the following:

git checkout alter_old
git branch -u origin/alter_old

but I get:

error: unknown switch `u'

And the same for --set-upstream-to.

EDIT: Strangely, I think that when I push, alterpushes into origin/master and alter_old pushed to origin/alter_old. Why is this?

1

There are 1 best solutions below

3
On BEST ANSWER

For git 1.8.0 onwards

git branch alter_old -u origin/alter_old

OR

git branch alter_old --set-upstream-to origin/alter_old

For git 1.7.0 : Use --set-upstream instead of --set-upstream-to

git branch --set-upstream alter_old origin/alter_old