2017-06-07 37 views
3

我有一個錯誤,使用Git 1.9。
當我嘗試「混帳推」我收到以下錯誤:GIT 1.9 - 遠程:錯誤:'receive.denyCurrentBranch'

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'. 

所以,我的第一步是在這個論壇在這裏讀了很多,並試圖找到從谷歌的一些結果。可悲的是,我發現我的情況並不奏效。

我在Linux x86上工作並安裝了Git 1.9。
我可以從我的服務器「git clone」一個存儲庫並在其中工作。
例如我在其中創建一個新文件「touch testfile」。現在我將「git commit」這個文件。
經過這一步我「git push」它,然後我得到錯誤代碼。

我在其他文章中發現,該問題已在git 2.3 中解決並且在配置文件中從存儲庫中更改「receive.denyCurrentBranch」的值應該有幫助。 有用的值應該是:refuseupdateInsteadignore

我想所有這些,誤差將始終是相同的。

在服務器的配置值IST:

[receive] 
     denyCurrentBranch = refuse 

和 「git branch

*master 

在客戶端中的 「git status」 是:

On branch master 
Your branch is ahead of 'origin/master' by 1 commit. 
    (use "git push" to publish your local commits) 

所以,誤差會隨時出現,我真的不知道如何解決它。
我該如何避免該錯誤信息?

+0

您是否得到了可幫助您解決問題的答案?如果是,您可以將其標記爲答案。它會幫助其他有類似問題的人。 –

回答

0

作爲git消息提示你,不建議'receive.denyCurrentBranch'。

我們通常使用遠程回購和本地回購進行版本控制。遠程回購是git真正版本控制的地方。通常遠程回購是裸露的。

因此,建議的方法是通過 git clone <URL of repo> --bare轉換遠程回購裸露在你的服務器,並把它作爲遠程回購,現在作爲遠程回購爲它工作。

現在你可以克隆上面的裸回購和提交/推送它。