Git学习之常见错误 git push 失败


问题描述:

git push
Counting objects: , done.
Delta compression using up to threads.
Compressing objects: % (/), done.
Writing objects: % (/), bytes | 445.00 KiB/s, done.
Total (delta ), reused (delta )
remote: error: refusing to update checked out branch: refs/heads/5.1
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 ...

解决办法:

这是由于git默认拒绝了push操作,根据提示信息解决:

You can set 'receive.denyCurrentBranch' configuration variable to 'ignore' or 'warn' in the remote repository to allow pushing into...

进入项目的目录下的.git目录,编辑config文件:

增加一项配置:

[receive]
denyCurrentBranch = ignore

然后再次执行 git push,就可以成功了。

这是服务器上看不到刚提交的文件,需要执行:

git reset --hard

然后就OK了。

在初始化远程仓库时最好使用 git init --bare

而不要使用:git init


Git学习之常见错误 git push 失败的更多相关文章

  1. Git学习之常见错误 clone被拒绝

    Git学习之常见错误 问题: git clone 时 报错 Permission Denied (权限被拒绝). 解决方法: 需要把本地的公钥上传到服务器. 解决步骤: ①第一步,设置本地的git的用 ...

  2. Git 学习笔记--删除错误提交的commit

    如果不小心把错误的commit给commit了,可以对其进行撤销 1.使用git log查看commit日志,找到错误提交前一版本commit的哈希值; 2.使用git reset --hard co ...

  3. Git学习笔记01--常用Git命令、cmd命令及Git总结性知识

    资源:外国网友制作的 Git Cheat Sheet 第二次学习廖雪峰老师的Git教程,学习过程中把教程中涉及到的Git命令及总结性知识记录下来方便二次复习. 知识点 所有的版本控制系统,其实只能跟踪 ...

  4. git学习利器:《Git Pro》中文版

    Git书籍有<版本控制之道git>,但是很一般.强烈推荐<Git Pro>中文版! 很多开源软件的教程也是免费开源的在线阅读的. <Git Pro>中文版在线阅读h ...

  5. Git学习笔记(windows git之初体验)

    阿里国内镜像地址: https://npm.taobao.org/mirrors/git-for-windows/ 最近在学习廖雪峰老师关于git的教程,链接可以在我的首页找到.首先使用国内镜像下载并 ...

  6. 【Git学习笔记】初始化Git仓库和版本回退

    学习地址 http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 什么是版本库呢?版本库又 ...

  7. git学习笔记03-本地git常用操作及原理-文件增删改

    1.查看git状态 git status  这个可以告诉我们对git做了哪些操,比如增删改 2.既然我们修改了东西,有的时候想看看修改了什么,毕竟我们的记忆力并不如电脑 git diff 文件名 (默 ...

  8. git学习笔记之二 -- git分支

    前面对git基础作了简单的总结,这次对git的杀手锏--分支做一总结. Git分支简介 几乎每个版本控制系统都以某种形式支持分支,可以使你的工作从开发主线上分离开来,以免影响开发主线.很多版本控制系统 ...

  9. git学习笔记——廖雪峰git教程

    OK,先附上教程--廖雪峰的官方网站 友情连接:git官网 简介 这里我只想引用他的原文: Linus可以向BitMover公司道个歉,保证以后严格管教弟兄们,嗯,这是不可能的.实际情况是这样的: L ...

随机推荐

  1. P1303 A*B Problem

    题目描述 求两数的积. 输入输出格式 输入格式: 两个数 输出格式: 积 输入输出样例 输入样例#1: 1 2 输出样例#1: 2 说明 需用高精 #include<iostream> # ...

  2. sed.exe 在bat中使用时,需要另外起一个文件

    今天在windows使用sed.exe时,同一个文件死活不生效,然后换了一个bat,再来调用,就可以了,怀疑跟sed.exe的代码有关.有时间再研究

  3. 伟景行 citymaker 从入门到精通系列

    伟景行 citymaker 从入门到精通(1)——js开发,最基本demo,加载cep工程文件 伟景行 citymaker 从入门到精通(2)——工程图层树加载   伟景行 citymaker 从入门 ...

  4. ubuntu 下service php5-fpm restart 报错 stop: Unknown instance: 解决

    问题描述: 在安装完扩展后,重启php-fpm,发现一直停止报错 stop: Unknown instance: 通过查看进程,也查询不到该主进程 解决办法: 干掉现在正在执行的进程 pkill ph ...

  5. Redis杂谈

    这是2015年初应邀在南华智闻作技术交流时所作的Redis方面的一个presentation. 因为原件是Keynote格式,已经转成PDF,点击下面链接打开或者下载PDF: Redis 杂谈

  6. HYSBZ 1503 郁闷的出纳员 (Splay树)

    题意: 作为一名出纳员,我的任务之一便是统计每位员工的工资.但是我们的老板反复无常,经常调整员工的工资.如果他心情好,就可能把每位员工的工资加上一个相同的量.反之,如果心情不好,就可能把他们的工资扣除 ...

  7. 阿里云服务器ECS部署应用教程

    购买阿里云服务器 大多数云服务器默认安装的语言运行环境版本都很旧了,python用的还是2.7,JDK用的还是1.6的,在ECS云服务器中可以自行安装,包括python3.4之类的. 在次页面购买EC ...

  8. Urlrewritefilte

    Urlrewritefilter是通过filter的形式,过滤所有的请求,然后再根据配置文件来转换成真正要访问的URL. 好处是隐藏真正的URL和美化提供给客户的URL. 比如,你的首页是www.** ...

  9. HashSet LinkedHashSet TreeSet 分析

    1.HashSet分析 hashset 底层是hash表,就是hashMap,是无序的,唯一的.也就是说,它的底层其实就是一个HashMap  key 值的组成值.所以具有唯一性. public Ha ...

  10. 遇到的django问题

    问题1: No migrations to apply 删除了migrations中0001_initial.py文件,重新执行 python manage.py makemigrations pyt ...