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

来源:互联网 发布:nrf24l01与单片机连接 编辑:程序博客网 时间:2024/05/19 04:54

问题:

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

$ git push origin masterCounting 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/masterremote: error: By default, updating the current branch in a non-bare repositoryremote: error: is denied, because it will make the index and work tree inconsistentremote: error: with what you pushed, and will require 'git reset --hard' to matchremote: error: the work tree to HEAD.remote: error:remote: error: You can set 'receive.denyCurrentBranch' configuration variable toremote: error: 'ignore' or 'warn' in the remote repository to allow pushing intoremote: error: its current branch; however, this is not recommended unless youremote: error: arranged to update its work tree to match what you pushed in someremote: error: other way.remote: error:remote: error: To squelch this message and still keep the default behaviour, setremote: 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

这样,其他机器提交代码就不会有问题。

阅读全文
0 0
原创粉丝点击