我是git的新手,我遇到了一个问题我在我的git系统中推送数据时遇到了问题。我安装了git和gitolite,但当我调用:"git push master master“时,它会给我这个错误:
Counting objects: 12, done.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (12/12), 1.47 KiB, done.
Total 12 (delta 1), reused 5 (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 gitolite@server.nl:gitolite-admin
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'gitolite@server.nl:gitolite-admin'我按照这篇教程安装了gitolite:gitolink,一切正常,但在最后一步。当我执行这个命令时,我很遗憾地得到了这个错误
有人能告诉我该怎么做或者怎么解决这个问题吗?已经尝试过了: git config --bool core.bare true修改分支(这样它(主)就不会被使用)
发布于 2011-08-05 08:36:53
基本的问题是,您试图推送到一个“非裸露的”git存储库。虽然这是可能的,但许多文档和书籍都没有明确表示不推荐这样做。
因此,虽然git是一个分散的/多主的scm,但在实践中,你倾向于拥有的是“主”或“中央”存储库,你从克隆并将推送到,作为“规范”存储库,以及从“主”复制的工作存储库(例如,在你的笔记本电脑上),你从“主”复制到,并从推送。这些“主”存储库应该使用--bare创建:
server$ cd ; mkdir git
server$ git clone --bare /home/user/foo /home/user/git/foo.git一旦你做到了这一点,你将能够从你的笔记本电脑上推送:
laptop$ cd foo
laptop$ git remote -v
laptop$ origin user@server:/home/user/git/foo.git (fetch)
laptop$ origin user@server:/home/user/git/foo.git (push)
laptop$ git push origin master您还可以在服务器上执行以下操作:
git config --global receive.denyCurrentBranch "ignore"但我不会这么做,除非你更好地了解git是如何工作的。
https://stackoverflow.com/questions/6941262
复制相似问题