2011-12-02 136 views
4

大約3個星期前,我從本地存儲庫中刪除了一些分支,但從未從GitHub上的存儲庫中刪除它們。我需要清理一些這些分支,但一直不成功。從GitHub刪除分支

舉個例子,我以前刪除這個分支從我的本地3周:1234e-proj

現在我試圖運行:

git push origin :1234e-proj 

,我得到這個錯誤:

error: unable to push to unqualified destination: 1234e-proj 
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 

任何想法我做錯了什麼?這發生在我已經在本地刪除的幾個分支。

回答

1

你有沒有嘗試使用

git push --delete origin '1234e-proj' 

git push --mirror origin # warning: pushes all refs and deletes all others! 

否則,應該工作。也許你可以共享

git branch -a 
+0

這裏是一些輸出: git push --delete origin'1234e-proj' remotes/origin/5370-event-模塊 遙控器/產地/ 5370-修訂 遙控器/產地/ 5370-路線 遙控器/ LV/5239h-ftaf 遙控器/ LV/5334-ftaf假期 遙控器/ LV/5334b-ftaf假期 我所用以1234e-proj爲例,但在嘗試從回購庫中刪除這些分支時出現同樣的錯誤。感謝您的幫助。 – mmalv

1

首先,胡亂猜測的輸出:是那些樹枝居然還在GitHub庫,在網絡上可見的,還是你只是看到他們在你的回購遠程分支機構? (運行git remote update --prune更新的東西,那將修剪他們,如果他們僅僅是在你的本地回購。)

使用git ls-remote origin打印遙控器上的裁判,作爲遠程​​看到他們,例如:

406da7803217998ff6bf5dc69c55b1613556c2f4 HEAD 
1e501a7c47ad5ada53d3b1acfb9f131f76e969ec refs/heads/maint 
406da7803217998ff6bf5dc69c55b1613556c2f4 refs/heads/master 
56e79320f3d9b044c380dfebf136584aaa17ac5b refs/heads/next 
... 

找到你要刪除的人,然後用git push :<ref>刪除,例如git push :refs/heads/branch-foo

我並不完全確定發生了什麼事情,但假設參考文件確實存在於遙控器上,這應該是一種查看和刪除它們的萬無一失的方法。我最好的猜測是你在GitHub上看到的ref實際上並不在refs/heads中,所以使用不合格的refname不起作用。 (我不知道你怎麼會在這種情況下結束,但是!

+0

'git remote update --prune'爲我工作 – hobs