git 如何使现有分支跟踪远程分支?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21729560/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make an existing branch track a remote branch?
提问by Mahmoud Adam
I'm trying to track an exiting branch to a remote branch using --track
or --set-upstream-to
, but got the following error
我正在尝试使用--track
or将退出分支跟踪到远程分支--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
I checked SourceTree and found that it uses --set-upstream
, but got the following warning
我检查了 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.
Both --track
and --set-upstream-to
is not working, Am I missing something?
双方--track
并--set-upstream-to
没有工作,我失去了什么?
回答by Mahmoud Adam
I think I got it, it will be as the following (used --set-upstream-to + remote name)
我想我明白了,它将如下所示(使用 --set-upstream-to + 远程名称)
$ git branch --set-upstream-to origin/master
Branch master set up to track remote branch master from origin.