您的位置:首页 > 编程语言

git 提交代码remote: error:updating the current branch in a non-bare repository is denied

2017-07-30 13:11 627 查看

问题:

开发机提交代码到远程仓库时,出错如下错误:

$ git push origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 267 bytes | 0 bytes/s, done.
Total 3 (delta 1), 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 git@192.168.12.70:/data/orange
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'git@192.168.12.70:/data/orange'


解决办法:

在服务器端仓库目录下

$ cd /data/orange
$ git config receive.denyCurrentBranch warn


更好的办法:

error信息中已经给出提示:

“By default, updating the current branch in a non-bare repository is denied,”

服务器上配置代码仓库时,将代码库初始化为裸仓库,即使用命令:

$ git init --bare


这样,其他机器提交代码就不会有问题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐