设置与remote branch对应的track branch

Git 1.7

1
git branch --set-upstream master origin/master

As of Git 1.8.0:

1
git branch -u upstream/foo 

Or, if local branch foo is not the current branch:

1
git branch -u upstream/foo foo 

Or, if you like to type longer commands, these are equivalent to the above two:

1
2
3
4
5
git branch --set-upstream-to=upstream/foo

或

git branch --set-upstream-to=upstream/foo foo