【原创】解决git push报错:remote: error: refusing to update checked out branch: refs/heads/master

blogdaren 2018-09-06 抢沙发 164人次

问题背景:

$ git push origin master
root@192.168.1.234's password:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 249 bytes | 249.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: 默认禁止更新非纯仓库的当前分支,因为您推送的内容将导致索引和工作区
remote: 不一致,并且将需要执行 'git reset --hard' 将工作区匹配到 HEAD。
remote:
remote: 您可以在远程仓库中设置 'receive.denyCurrentBranch' 配置变量为
remote: 'ignore' 或 'warn' 以允许推送到当前分支。然而不推荐这么做,除非您
remote: 用某种方式将其工作区更新至您推送的状态。
remote:
remote: 若要屏蔽此信息且保持默认行为,设置 'receive.denyCurrentBranch'
remote: 配置变量为 'refuse'。
To ssh://192.168.1.234/tmp/test/.git
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://root@192.168.1.234/tmp/test/.git'

问题原因:

其实报错提示很明显:git 默认拒绝 push 操作

解决方案:

修改/path/to/test/.git/config文件,在文件最后新增如下代码:

[receive]
denyCurrentBranch = ignore

版权声明:除非注明,本文由( blogdaren )原创,转载请保留文章出处。

本文链接:【原创】解决git push报错:remote: error: refusing to update checked out branch: refs/heads/master

发表评论:

您的昵称:
电子邮件:
个人主页: