如何更改git分支正在跟踪的远程? [英] How do I change the remote a git branch is tracking?
问题描述
中央
存储库必须在新服务器上设置,所以我在本地仓库上创建了一个新的远程服务器,并推送到该服务器。 但现在当我做 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屋!