How to make an existing branch track a remote branch?

只愿长相守 提交于 2019-12-09 15:29:07

问题


I'm trying to track an exiting branch to a remote branch using --track or --set-upstream-to, but got the following error

$ 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

$ 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?


回答1:


I think I got it, it will be as the following (used --set-upstream-to + remote name)

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


来源:https://stackoverflow.com/questions/21729560/how-to-make-an-existing-branch-track-a-remote-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!