如何更改分支跟踪的远程位置? [英] How to change the remote a branch is tracking?

查看:74
本文介绍了如何更改分支跟踪的远程位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

必须在新服务器上设置central存储库,因此我在本地存储库上创建了一个新的远程服务器,并将其推送到该服务器.

The central repository had to be set up on a new server, so I created a new remote on my local repo, and pushed to that.

但是现在当我执行git pull时,它声称我是最新的.这是错误的-它是在告诉我有关 old 远程分支的信息,而不是关于新分支的信息,因为我知道事实上有新的提交要提取.

But now when I do git pull, it claims I am up to date. It's wrong—it's telling me about the old remote branch, not the new one, which I know for a fact has new commits to fetch.

如何更改本地分支以跟踪其他遥控器?

How do I change my local branch to track a different remote?

我可以在git config文件中看到它,但是我不想弄乱.

I can see this in the git config file but I don't want to mess things up.

[branch "master"]
    remote = oldserver
    merge = refs/heads/master

推荐答案

使用 git v1.8.0 或更高版本:

Using git v1.8.0 or later:

git branch branch_name --set-upstream-to your_new_remote/branch_name

或者您可以使用-u开关

git branch branch_name -u your_new_remote/branch_name

使用git v1.7.12 或更早版本

Using git v1.7.12 or earlier

git branch --set-upstream branch_name your_new_remote/branch_name

这篇关于如何更改分支跟踪的远程位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆