git分支--set-upstream的相反操作

41

我希望停止跟踪某些分支。 我使用git branch --set-upstream foo origin/foo进行了跟踪设置。

我该如何撤销这个操作?

3个回答

50

在即将发布的 Git 1.8 中,您将能够执行以下操作:

git branch --unset-upstream

不过,目前您需要像 manojlds建议的那样,使用两个git config --unset命令。


1
而具有讽刺意味的是,git branch --set-upstream 正在被弃用。 - manojlds
顺便问一下,取消选项的来源在哪里?我在发布说明中没有看到它。 - manojlds
@manjolds:它是在这个提交中引入的,并且在v1.8.0-rc0、v1.8.0-rc1和v1.8.0-rc2中存在。 - Mark Longair

27

尝试以下内容:

git config --unset branch.<branch>.remote
git config --unset branch.<branch>.merge

2
如果我理解正确,您想要删除本地分支和远程分支之间的关联...我认为最简单的方法之一应该是通过编辑配置文件 (.git/config) 实现。 您可以在这里找到与您问题相关的内容

To remove the association between the local and remote branch, and delete the local branch, run:

git config --unset branch.<branch>.remote
git config --unset branch.<branch>.merge
git branch -d <branch>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接