七寸殇

  • 主页
  • 随笔
所有文章 友链 关于我

七寸殇

  • 主页
  • 随笔

git使用push时报错:remote:error:refusing to update checked out branch:refs/heads/master的解决办法

2018-02-06

本地push到远程仓库时,如果远程仓库不是裸仓库,也就是创建时使用的git init而不是git init –bare,会发生如下错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
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 som
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To xxx.xxx.xxx.xxx:/data/python/python3/django/post308
! [remote rejected] master -> master (branch is currently checked out)

解决方法:
修改远程仓库项目目录下的.git/config,加入:

1
2
[receive]
denyCurrentBranch = false

然后push就不会报错了,但是这样只是git文件更新了,远程项目并不会更新,解决方法:

1
git reset --hard

这样就可以查看push后的项目了。

赏

谢谢你请我吃糖果

支付宝
微信
  • git
  • push
  • remote

扫一扫,分享到微信

微信分享二维码
闲鱼pc端如何使用关键词搜索
django利用requests获取接口/网页内容
© 2023 七寸殇
总访问量:, 页面访问量
  • 所有文章
  • 友链
  • 关于我

tag:

  • composer
  • 镜像
  • laravel
  • ab.exe
  • 性能测试
  • apache
  • 交换变量
  • 面试题
  • 位运算
  • 阿里云
  • git
  • django
  • python
  • hexo
  • blog
  • github
  • docker
  • docker-compose
  • eclipse
  • tomcat
  • 环境变量
  • requests
  • api
  • php
  • 下载完成
  • mysql
  • 数据库
  • 脏读
  • 不可重复读
  • 幻读
  • merge
  • 分支
  • 合并
  • abort
  • push
  • remote
  • pull
  • .gitignore
  • reset
  • hooks
  • redis
  • appends
  • 分页
  • paginate
  • header
  • response
  • linux
  • php7
  • nginx
  • 500错误
  • php.ini
  • display_errors
  • Auth
  • guard
  • session
  • 路由
  • route
  • validate
  • 验证
  • group_concat
  • concat
  • raw
  • 数据库查询
  • 一对多
  • 笛卡尔集
  • lnmp
  • find
  • 远程登录
  • 忘记密码
  • ThinkPHP
  • url重写
  • 路由重写
  • proxy_pass
  • 反向代理
  • foreach
  • 最后一个元素
  • get_cfg_var
  • ini_set
  • ini_get
  • ini_get_all
  • ini_restore
  • 反射
  • 类的所有方法
  • 命名规范
  • 闭包
  • 引用
  • pytesser
  • 图片识别
  • windows
  • tesseract-ocr
  • RESTful
  • 无状态
  • Statelessness
  • selenium
  • phantomjs
  • 爬虫
  • svn
  • 微信小程序
  • wxParse
  • 微信
  • 成语猜猜看
  • vagrant
  • while
  • 素数
  • 算法
  • ssh
  • setData
  • 上拉加载
  • log
  • 闲鱼
  • html

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

Make More Time