2013-10-01 163 views
6

我怎樣才能推動一個分支到不同的回購與分支的新名稱。git推分支到一個新的不同名稱的回購

例如我有一個分支feature1在回購abc,我想推動回購xyz並使其成爲主分支。

我嘗試使用Renaming remote git branch但隨後在新的回購做一個git克隆後,我得到了錯誤消息

混帳警告:遠程HEAD是指不存在的參考,無法結帳

是有一種方法可以在推送中指定我想要的目標分支名稱是什麼?

回答

15

我認爲這應該工作:在

git push -f xyz feature1:master 
git push xyz +feature1:master 

從man頁面(在例子部分:

git push xyz feature1:master 

如果主人已經存在,你可以用-f/--force,或+破壞它結束):

git push origin +dev:master 
     Update the origin repository’s master branch with the dev branch, 
     allowing non-fast-forward updates. [...] 
+2

這很好,但如果分支不存在,它需要使用/ refs/heads/master,例如。 git push xyz feature1:refs/heads/master –

相關問題