git push提交时报错,拒绝提交

今天初次创建了git项目,并尝试将代码提交,但是报错,一直拒绝提交,错误如下:

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@xxx.xxx.xxx.xxx:ldlogistics.git  
 ! [remote rejected] master -> master (branch is currently checked out)  
error: failed to push some refs to 'git@xxx.xxx.xxx.xxx:ldlogistics.git'


在网上查了很久,最终解决办法如下:

在服务器的ldlogistics.git中有隐藏文件夹.git  ,修改.git下的config文件,在文件末尾添加

[receive]
    denyCurrentBranch = ignore  

然后就能提交了(先是修改了本地的该文件,但是没有生效,后来修改了服务器上的就好了,也不知道是否两个地方都需要改或是只需要改服务器的)

posted @   寂地烟火  阅读(58)  评论(0编辑  收藏  举报  
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示