[remote rejected] master -> master (branch is currently checked out)
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'.
git shell 是一個使用 git repository 所使用的安全 shell,僅能進行 git commit , push 等操作,至於為什麼會出現這樣的錯誤訊息?
這是由於在建立倉庫時使用的不是 "裸庫" 的原因,所謂的裸庫就是在建立 git repository 時會使用以下參數
$ git init --bare
但你若是沒有加入 --bare 就是文中提到的 non-bare repository,並且包含 work tree 只要和當前 work tree 的 branch 衝突就會導致失敗。
$ git init
這樣你在進行 git push 的時候 git-shell 就會禁止你 push,而在文中也提到可以加入 receive.denyCurrentBranch 來解決這個問題
$ vim .git/config
[receive]
denyCurrentBranch = ignore
如果在建立共用 git repository 建議還是採用 git init --bare 來初始化裸庫!!
Orignal From: Git 改為 git-shell 後無法 git push
沒有留言:
張貼留言