如何停止跟踪 Git 中的远程分支? [英] How do you stop tracking a remote branch in Git?
问题描述
如何停止跟踪 Git 中的远程分支?
我要求停止跟踪,因为在我的具体情况下,我想删除本地分支,而不是远程分支.删除本地分支并将删除推送到远程也会删除远程分支:
我可以只做 git branch -d the_branch
,而且当我以后 git push
时它不会被传播吗?
它只会在我稍后运行 git push origin :the_branch
时传播吗?
如 Yoshua Wuyts 中所述' 答案,使用 git branch
:
git branch --unset-upstream
其他选项:
您不必删除本地分支.
只需删除跟踪远程分支的本地分支:
git branch -d -r origin/<远程分支名称>
-r, --remotes
告诉 git 删除远程跟踪分支(即删除设置跟踪远程分支的分支).这将不要删除远程仓库上的分支!
没有本地跟踪分支的概念,只有远程跟踪分支.
所以origin/master
是origin
repo
master
的远程跟踪分支如 Dobes Vandermeer 的 答案,您还需要重置与本地分支关联的配置:
git config --unset branch..remotegit config --unset branch..merge
<块引用>
删除
的上游信息.
如果没有指定分支,则默认为当前分支.
(git 1.8+,2012 年 10 月,commit b84869e by 卡洛斯·马丁·涅托 (carlosmn
))
这将使任何推/拉完全不知道origin/
.
How do you stop tracking a remote branch in Git?
I am asking to stop tracking because in my concrete case, I want to delete the local branch, but not the remote one. Deleting the local one and pushing the deletion to remote will delete the remote branch as well:
Can I just do git branch -d the_branch
, and it won't get propagated when I later git push
?
Will it only propagate if I were to run git push origin :the_branch
later on?
As mentioned in Yoshua Wuyts' answer, using git branch
:
git branch --unset-upstream
Other options:
You don't have to delete your local branch.
Simply delete the local branch that is tracking the remote branch:
git branch -d -r origin/<remote branch name>
-r, --remotes
tells git to delete the remote-tracking branch (i.e., delete the branch set to track the remote branch). This will not delete the branch on the remote repo!
See "Having a hard time understanding git-fetch"
there's no such concept of local tracking branches, only remote tracking branches.
Soorigin/master
is a remote tracking branch formaster
in theorigin
repo
As mentioned in Dobes Vandermeer's answer, you also need to reset the configuration associated to the local branch:
git config --unset branch.<branch>.remote
git config --unset branch.<branch>.merge
Remove the upstream information for
<branchname>
.
If no branch is specified it defaults to the current branch.
(git 1.8+, Oct. 2012, commit b84869e by Carlos Martín Nieto (carlosmn
))
That will make any push/pull completely unaware of origin/<remote branch name>
.
这篇关于如何停止跟踪 Git 中的远程分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!