如何更改git分支正在跟踪的远程? [英] How do I change the remote a git branch is tracking?

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

问题描述

中央存储库必须在新服务器上设置,所以我在本地仓库上创建了一个新的远程服务器,并推送到该服务器。



但现在当我做 git pull 时,它声称我是最新的。这是错误的 - 它告诉我关于旧的远程分支,而不是新的远程分支,我知道这是一个新的提交提取。



如何更改我的本地分支以跟踪不同的远程?



我可以在git配置文件中看到这一点,但我不想搞砸东西。 / b>

  [branchmaster] 
remote = oldserver
merge = refs / heads / master


解决方案

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



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



或者您可以使用 -u switch:



git branch branch_name -u your_new_remote / branch_name



使用git v1.7.12 或更低版本:



git branch --set-upstream branch_nam e your_new_remote / branch_name


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.

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?

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

解决方案

Using git v1.8.0 or later:

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

Or you can use the -u switch:

git branch branch_name -u your_new_remote/branch_name

Using git v1.7.12 or earlier:

git branch --set-upstream branch_name your_new_remote/branch_name

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

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