如何使现有分支跟踪远程分支?

时间:2014-02-12 13:39:40

标签: git github atlassian-sourcetree

我正在尝试使用--track--set-upstream-to跟踪退出分支到远程分支,但出现以下错误

$ git branch --track master origin/master
fatal: A branch named 'master' already exists.   
$ git branch --set-upstream-to master origin/master
fatal: branch 'origin/master' does not exist   

我检查了SourceTree,发现它使用了--set-upstream,但收到了以下警告

$ git branch --set-upstream master origin/master
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
Branch master set up to track remote branch master from origin.

--track--set-upstream-to都不起作用,我错过了什么吗?

1 个答案:

答案 0 :(得分:15)

我想我明白了,它将如下(使用--set-upstream-to + remote name)

$ git branch --set-upstream-to origin/master
Branch master set up to track remote branch master from origin.