通常在用git clone了remote端(服务器)的git仓库后,再进行了自己一系列修改后,会将自己测试后稳定的状态push到remote端,以更新源仓库,使 其他人在pull的时候得到自己的修改。但是在git push的时候会经常出现如下的错误提示。

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’.

根据上面所报的信息,它的意思就是默认情况下,git不允许用push操作更新non-bare的仓库,因为这样的操作会导致remote仓库的索引 (index)和工作树(work tree)与你push的不一致,此时需要通过‘git reset –hard’操作来使得工作树与HEAD索引相匹配。 可以通过在remote端,设置git的配置文件(.git/config),在其中添加如下内容: [receive]

[receive]
denyCurrentBranch = ignore

这样就可以通过git push提交自己的稳定更新,要想在push后在remote端看到更新的效果,执行git reset –hard即可。

ssh://root@xxx.xxx.xxx.xxx:/data0/htdocs/order

git push remote error解决办法的更多相关文章

  1. git push失败的解决办法(2)

    错误一:Cannot rebase: You have unstaged changes 解决办法: Cannot rebase: You have unstaged changes. 那说明有修改过 ...

  2. git push出错的解决办法

    今天push代码到线上的时候怎么都不行,尝试了很多办法报了好几种错比如: 反正就是各种错,然后其实不管什么错,你全部Git init 一下然后重新配置 git config --global user ...

  3. unable to access 'https://github.com/shixianqing/img.git/': SSL connect error 解决办法

    解决在linux环境下,git clone 项目,走https协议时,报SSL connect error 错误 升级nss yum update -y nss curl libcurl

  4. windows下git bash中文乱码解决办法

    一.解决办法1:(直接上图) 1.在git bash下,右键 出现下图,选择options: 2.选择“Text” 3.将“Character set”设置为  UTF-8 转:windows下git ...

  5. git push throws error: RPC failed; result=22, HTTP code = 411的解决办法

    原因:默认 Git 设置 http post 的缓存为 1MB,将其设置为 500MB 解决办法如下: git config http.postBuffer 524288000

  6. Git - could not read Username for 'https://github.com',push报错解决办法

    执行git push命令异常,如下: git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sou ...

  7. 解决git push出现error: failed to push some refs to 错误

    错误截图 背景 码云上创建了空项目 本地项目绑定了远程仓库,尝试git push,然后报了错 解决办法 使用强制命令git pull origin master --allow-unrelated-h ...

  8. git学习之冲突解决办法

    1.如果本地项目和远程服务器的同一文件都有改动,那么就会产生冲突,导致git pull 失败,报错见下. 解决办法:先执行git stash指令,暂存当前的改动状态,再执行git pull指令,就可以 ...

  9. Linux] Git: push 出错的解决 master -> master (branch is currently checked out)

      在使用Git Push代码到数据仓库时,提示如下错误: [remote rejected] master -> master (branch is currently checked out ...

随机推荐

  1. View类的XML属性、相关方法及说明

    XML属性 相关方法 说明 android:alpha setAlpha(float) 设置该组件的透明度 android:background setBackgroundResource(int) ...

  2. 注意Hibernate4在开发当中的一些改变(转)

    注意Hibernate4在开发当中的一些改变 原文:http://hi.baidu.com/austincao/item/fc9907da3d854e44fa576861 Hibernate4的改动较 ...

  3. 转 windows查看端口占用命令

    转自  http://www.cnblogs.com/allenblogs/archive/2010/06/25/1765055.html 开始--运行--cmd 进入命令提示符 输入netstat ...

  4. 如何写UI及屏幕适配的一些技巧

    总结一下关于UI布局及屏幕适配的一些实战技巧,尤其使用纯代码,会对提升效率及代码易于维护等方面有明显帮助,这里提到的没有使用任何Xib, 如果不是在外包公司,也推荐大家多使用甚至完全使用纯代码布局UI ...

  5. 超酷的 Vim 搜索技巧

    尽管目前我们已经涉及 Vim 的多种特性,但此编辑器的特性集如此庞大,不管我们学习多少,似乎仍然远远不足.承接我们的 Vim 教程系列,本文我们将讨论 Vim 提供的多种搜索技术. 不过在此之前,请注 ...

  6. React(0.13) 定义一个input组件,使其输入的值转为大写

    <!DOCTYPE html> <html> <head> <title>React JS</title> <script src=& ...

  7. 环信集成 2---基于环信Demo3.0,实现单聊功能

    这几天在做环信,所以把环信相关的东西拿过来,做个系统点的东西 注意: 这里Demo集成的是带有实时语音功能的(libEaseMobClientSDK.a). 环信库是直接拖拽EaseMobSDK文件夹 ...

  8. hibernate 注释 唯一键约束 uniqueConstraints

    @Table 注解包含一个schema和一个catelog 属性,使用@UniqueConstraints 可以定义表的唯一约束. 如果是联合约束就用下面这种 @Table(name="tb ...

  9. git使一个非仓库型的工程可以推送

    git config receive.denycurrentbranch false

  10. WinRAR破解

    新建记事本文件(txt文件),然后将文件另存为以 rarreg.key 为文件名的文件(当然由于设置的不同,可能出现你保存后的文件为 rarreg.key.txt 没关系,将其重命名,删掉.txt 会 ...