Git - 删除本地跟踪分支

4
我已经删除了一些远程分支(dev/featureAdev/featureB),但是当我运行 git remote show origin 命令时,我仍然可以在本地分支部分看到它们的列表。例如:
$ git remote show origin

Local branches configured for 'git pull':
  dev/featureA                  merges with remote dev/featureA
  dev/featureB                  merges with remote dev/featureB

我需要禁用跟踪功能或类似的功能吗?

3个回答

4

这对我有用。

 git branch -r -d dev/featureA

3
要完全从本地跟踪中删除远程存储库,请执行以下操作:git remote remove <remoteRepo> 要明确地仅删除特定本地分支的上游跟踪,请执行以下操作:git branch --unset-upstream <branch name>,例如:git branch --unset-upstream dev/featureA 要删除所有不再在远程可用的陈旧本地分支,请执行以下操作:git remote prune <remoteRepo>。建议先使用--dry-run选项进行试运行。
更多信息请参见http://git-scm.com/docs/git-branchhttp://git-scm.com/docs/git-remote

2

请尝试使用以下命令:

git fetch origin --prune

这个命令是用来删除已经被删除的分支的。 如果不行,请访问这个链接,看看其中的一些命令是否能帮助您。 祝好!


对我来说没有用致命错误: 拒绝在非裸库的当前分支refs/heads/<branchName>中获取。 - Developer
完美。删除了本地跟踪分支,这些分支在远程服务器上没有关联的分支。 - cjtkirk

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