問題:如果工作樹不是裸露的,我如何將我的本地提交推送到我的開發服務器?使用git + post-receive hook管理網站:錯誤推送更改
我的情況:
- 我設置的git我的開發服務器上,這樣,當我推的局部變化,它們被添加到一個分離的工作樹(如described here和很像this post)。
- 然後我遇到了在dev服務器上運行git的問題(例如,
git status
),因爲git找不到工作樹。 - 我詢問了SO和got the tip off,我需要在我的配置文件中設置
bare = false
並指定工作樹。甜。
但現在,當我試圖把我提交到開發服務器我得到這個錯誤:
$ git push origin master
[email protected]'s password:
Counting objects: 26, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (18/18), 2.56 KiB, done.
Total 18 (delta 8), 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 ssh://[email protected]/xxx/xxx/xxxxxx.git
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://[email protected]/xxx/xxx/xxxxxx.git'
我看到this other user had the same problem。不幸的是,爲他工作的解決方案是在他的配置中設置了bare = true
,這將重新創建我在上面的第3步中遇到的問題。
錯誤消息說
You can set 'receive.denyCurrentBranch' configuration variable to remote: error: 'ignore' or 'warn'
對我來說,是它確定爲我做到這一點?這聽起來不錯,但我沒有足夠的熟悉混帳尚未承認一個壞主意,當談到身邊......
編輯
只是要清楚,我已經添加了一個帖子接收鉤並且工作順利。問題是我似乎不得不在bare=true
(並能夠推送到dev服務器)和bare=false
(並且能夠在dev服務器上運行git命令)之間進行選擇。
真的嗎?現在是1歲。我敢打賭你終於設置了裸回購。大概應該接受VonC的答案吧! :P – cregox