![Git 不会推送到服务器上的裸存储库](https://linux22.com/image/1371037/Git%20%E4%B8%8D%E4%BC%9A%E6%8E%A8%E9%80%81%E5%88%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%9A%84%E8%A3%B8%E5%AD%98%E5%82%A8%E5%BA%93.png)
我刚刚在服务器上安装了 Gitolite,所以我推送到其中的任何存储库都应该是裸存储库,我甚至进入了 repo 目录,并git init --bare
在其中运行以确保它们是裸存储库,但是当我尝试推送到它们时,我仍然收到此错误消息:
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 config receive.denyCurrentBranch ignore
尝试将它推送到远程仓库,但错误仍然出现。
我不确定我在这里做错了什么。
答案1
您不应该git init --bare
自己去跑。
gitolite.conf
只需在 repo文件中声明一个新的 repo 名称gitolite-admin
,将其推回到 gitolite 服务器,gitolite 本身就会正确创建该 repo(在 中~/repositories/mynewrepo.git
,作为裸 repo)
答案2
我发现,如果 Gitolite 服务器上有用户,Git 将登录该用户,而不是通过 Gitolite,但我没有意识到这一点。而且,我还有一个试图推送到用户目录中的存储库副本,因此它当然不是空的。