2011-07-12 88 views
0

我在本地機器上有一個git repo。我將(最初)這個推到一個遠程(網絡服務器),我檢查遠程(在遠程),以便文件可以由Apache服務,我改變我的本地,commit -a它的文件,然後我試着再推一遍我總是會遇到一個錯誤。這對於Svn來說非常簡單,我如何用git來做到這一點?git遠程錯誤

Counting objects: 5, done. 
Delta compression using up to 2 threads. 
Compressing objects: 100% (3/3), done. 
Writing objects: 100% (3/3), 298 bytes, done. 
Total 3 (delta 2), reused 0 (delta 0) 
remote: error: refusing to update checked out branch: refs/heads/Dev 
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 inconsist 
ent 
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. 
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set 
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. 
To ssh://[email protected]/var/www/UML/.git 
! [remote rejected] Dev -> Dev (branch is currently checked out) 
error: failed to push some refs to ......' 
+4

我沒有看到任何錯誤... – KingCrunch

+0

由於這不是程序員的危險,如果您也發佈錯誤,那將是非常好的。 – moritz

+0

[git push error'remote rejected \] master - > master(branch is currently checked out)']的可能重複(http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master - 主分支 - 是 - 目前進行確認的鷗) – manojlds

回答

0

您不應推送到非裸存儲庫。有一個第三次回購週期性地從你推動的回購。 Git不會改變你的遠程工作目錄,而無需從遠端進行顯式的操作。

你正在處理一個DVCS和push vs pull的概念是一個重要的。

欲瞭解更多信息,請參閱progit.org/book。

希望這會有所幫助。

0

暫時,在服務器上創建一個新的臨時黨支部,讓你推:

git checkout -b temp 

這可以確保你正在推動當前分支未簽出。現在你的推動應該通過。

在Git中有一個裸機和工作回收的概念,而您推動的「中央」回購 - 回購通常是裸機。這是一種最佳做法,可以防止你受到很大的痛苦。您也可以將您的當前回購在服務器上爲裸回購:

git config --bool core.bare true 

(然後刪除一切,除了.git

或者,按照@adymitruk說什麼。在繼續之前瞭解有關Git和DVCS的更多信息。

相關問題