git 提交代码remote: error:updating the current branch in a non

阅读: 评论:0

git 提交代码remote: error:updating the current branch in a non

git 提交代码remote: error:updating the current branch in a non

问题:

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

$ 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

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

本文发布于:2024-02-03 01:00:48,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170689326747629.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:代码   remote   git   error   branch
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23