Arp*_*wat 15 git github remote-branch git-branch
我有2个远程分支:
- pending-issues-in-project
- new-issues-in-project
Run Code Online (Sandbox Code Playgroud)
我试图删除pending-issues-in-project这样:
git push origin :pending-issues-in-project,但我收到错误:
error: unable to push to unqualified destination: pending-issues-in-project
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
error: failed to push some refs to 'git@github.com:forkedRepo/RepoName.git'
Run Code Online (Sandbox Code Playgroud)
所以我想可能是我已删除pending-issues-in-project分支,但当我运行
git branch -a它显示pending-issues-in-project列表中的分支.
当我尝试相同(尝试删除)时new-issues-in-project,它工作.
我已经从本地服务器中删除了两个分支git branch -D branchName.
如果错误即将发生,因为存储库中不存在分支,那么为什么它会进入远程分支列表?
和
有什么办法来强制删除远程分支的?
谢谢你的时间.
man*_*lds 19
你必须做:
git remote prune origin
Run Code Online (Sandbox Code Playgroud)
删除本地git存储库中的远程跟踪分支(修剪将删除远程源中不存在的任何分支).在那之后,你不会看到它git branch -a
小智 8
您所看到的分支就是所谓的远程[跟踪]分支.它位于您的本地存储库中,它代表您在远程存储库中看到该分支的最后一个位置.Git使用这样的分支,这样你就不必每次想要处理远程存储库; 您只需更新/获取一次,远程货架分支就会更新,您可以从中进行操作.在您的情况下,远程存储库中的分支很久就被删除了; 您只需要删除本地存储库中的副本.
删除它有两种主要方法:
git branch -d -r origin/pending-issues-in-project只删除那个分支; 和git remote prune origin删除所有这些陈旧的远程分支.您也可以同时更新:git remote update --prune origin