2016-12-26 25 views
0

我在mac os x上啓用了ssh。我試圖推動本地更改爲遠程回購。我在本地模擬遠程回購這樣的:創建遠程回購Git推到裁判/頭/主無法在我的Mac,如何解決?

$cd ~/learn 
$mkdir gittest 
$cd gittest/ 
$git init 
$git config --global user.name "username" 
$git config --global user.email "useremail" 
$touch readme 
$git add readme 
$git commit -m "empty" 

OK,一切正常,然後在另一個目錄中,我所做的:

$cd ~/learn/client 
$git clone [email protected]:/Users/trosky/learn/gittest 
$cd gittest 
$vi readme(add one line) 
$git add . 
$git commit -m "add line" 
$git push origin master:refs/heads/master 

它沒有和git說:

$git push origin master:refs/heads/master 
Total 0 (delta 0), reused 0 (delta 0) 
remote: error: refusing to update checked out branch: refs/heads/master 
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. 
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set 
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. 
To [email protected]:/Users/trosky/gittest 
! [remote rejected] master -> master (branch is currently checked out) 
error: failed to push some refs to '[email protected]:/Users/trosky/learn/gittest' 

這是否表明遠程回購或本地客戶端有問題?如何解決它?

+0

該消息說明究竟發生了什麼,你能解釋它的哪一部分讓你感到困惑嗎? – jthill

回答

0

錯誤消息告訴你(你試圖推送的遠程並不是裸露的回購,事實上......)你嘗試推送到的分支在該存儲庫中檢出。默認情況下,不允許推送到非裸露的回購站,並且不允許推送到檢出分支。但是,您可以通過在遠程系統上進行git config更改來配置遠程系統以允許它顯示錯誤消息。

我懷疑如果你使用了錯誤信息,你會發現許多現有的網站給出了相同的答案。

+0

錯誤消息根本不說。它說你不能推到檢出分支。推動工作回購是有用的,即使是普通的。 – jthill

+0

謝謝@jthill。更新了答案。 – Mort

+0

這仍然是錯誤的。 – jthill

相關問題