如何停止跟踪 Git 中的远程分支?
我要求停止跟踪,因为在我的具体情况下,我想删除本地分支,而不是远程分支。删除本地分支并将删除推送到远程将同时删除远程分支:
我可以只执行 git branch -d the_branch
,而当我稍后 git push
时它不会传播吗?
它只会在我稍后运行 git push origin :the_branch
时传播吗?
最佳答案
如 Yoshua Wuyts 中所述' answer , 使用 git branch
:
git branch --unset-upstream
其他选项:
您不必删除本地分支。
只需删除正在跟踪远程分支的本地分支:
git branch -d -r origin/<remote branch name>
-r, --remotes
告诉 git 删除远程跟踪分支(即删除分支集以跟踪远程分支)。这will not delete the branch on the remote repo !
参见“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
如 Dobes Vandermeer 中所述的 answer ,您还需要重置与本地 分支关联的配置:
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+,2012 年 10 月,commit b84869e Carlos Martín Nieto ( carlosmn
) )
这将使任何推/pull 完全不知道 origin/<remote branch name>
.
关于git - 你如何停止跟踪 Git 中的远程分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3046436/