2013-06-19 108 views
1

我有兩個回購在我的本地機器上,說local1local2。所以,我從local1推入一個非裸回購 - 在我的本地,兩個回購Git

git push local2 sombranch 

跑了,我得到這個

remote: error: refusing to update checked out branch: refs/heads/5-0-stable 
remote: error: By default, updating the current branch in a non-bare repository 
remote: error: is denied, because it will make the index and work tree inconsistent 
remote: error: with what you pushed, and will require 'git reset --hard' to match 
remote: error: the work tree to HEAD. 
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to 
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into 
remote: error: its current branch; however, this is not recommended unless you 
remote: error: arranged to update its work tree to match what you pushed in some 
remote: error: other way. 

兩個回購幾乎一模一樣的歷史和sllight分歧無法進入衝突。我被迫改變了receive.denyCurrentBranch?我真的不希望通過這個命令,打開遠程回購的回購裸git config --bool core.bare true

回答

1

您有幾種選擇,如果你不想做local2裸回購:

1)設置receive.denyCurrentBranch。但我認爲這個git錯誤信息非常清楚地解釋了這會在以後如何導致問題,所以最好避免這種情況。

2)檢查local2中的不同分支,然後從local1執行推送。只有當您試圖推送到在遠程存儲庫中籤出的分支時纔會出現此錯誤,因此您可以通過在其中檢出不同的分支來避免它(這也消除了錯誤中描述的工作樹/ HEAD同步的問題。)

3)也許是最簡單的,從local2,只是這樣做:

git pull local1 

由於git pull更新所有三個頭,索引和工作樹,沒有同步問題,好像有與git push,只改變頭。

+0

感謝1)我不想那麼做。但是,你能解釋一下爲什麼會發生這種情況:當你拉扯的時候沒有pb?順便說一下,你能否更深入地解釋PLZ 2)(我理解命令而不是底層思想) – Newben