本文介绍了Git说,当我删除远程分支时,远程引用不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我跑了 git branch -a * master remotes / origin / test remotes / origin / master 我想删除我的远程分支 我试过了 git push origin - 删除remotes / origin / test 我得到了 错误:无法删除'远程/源/测试':远程参考不存在存在 它怎么不存在? 我做了一个 git branch -a ,我看到它列出。 我错过了什么吗? git branch -a 显示存在的远程分支 em>在您的本地存储库中。这听起来有点令人困惑,但要理解它,您必须明白,远程分支和远程存储库中存在的分支之间存在差异。远程分支是映射到远程存储库分支的 local 分支。因此,这组远程分支表示远程仓库的状态。 更新远程分支列表的常用方法是使用 git fetch 。这会自动从远程获取更新的分支列表,并在本地存储库中设置远程分支,同时获取可能缺失的任何提交对象。 但是,默认情况下, git fetch 不会删除远程分支不再有对应分支的远程分支。为了做到这一点,你需要明确地修剪远程分支的列表: git fetch --prune 这将自动消除遥控器上不存在的远程分支。之后, git branch -r 会显示一个真正存在于远程的分支的更新列表:可以使用 git push code>。 就是说,为了使用 git push --delete ,您需要指定远程存储库上分支的名称;不是你远程分支的名字。因此,要删除分支 test (由您的远程分支 origin / test 表示),您可以使用 git push origin --delete test 。 I ran git branch -a * master remotes/origin/test remotes/origin/masterI want to delete my remote branch I've tried git push origin --delete remotes/origin/testI got error: unable to delete 'remotes/origin/test': remote ref does not existHow is it not exist ? I did a git branch -a, and I saw it listed. Did I miss anything ? 解决方案 The command git branch -a shows remote branches that exist in your local repository. This may sound a bit confusing but to understand it, you have to understand that there is a difference between a remote branch, and a branch that exists in a remote repository. Remote branches are local branches that map to branches of the remote repository. So the set of remote branches represent the state of the remote repository.The usual way to update the list of remote branches is to use git fetch. This automatically gets an updated list of branches from the remote and sets up remote branches in the local repository, also fetching any commit objects you may be missing.However, by default, git fetch does not remove remote branches that no longer have a counterpart branch on the remote. In order to do that, you explicitly need to prune the list of remote branches:git fetch --pruneThis will automatically get rid of remote branches that no longer exist on the remote. Afterwards, git branch -r will show you an updated list of branches that really exist on the remote: And those you can delete using git push.That being said, in order to use git push --delete, you need to specify the name of the branch on the remote repository; not the name of your remote branch. So to delete the branch test (represented by your remote branch origin/test), you would use git push origin --delete test. 这篇关于Git说,当我删除远程分支时,远程引用不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-16 21:32