zoukankan      html  css  js  c++  java
  • Git学习之常见错误 git push 失败

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


    问题描述:

    git push
    Counting objects: 6, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (4/4), done.
    Writing objects: 100% (6/6), 445 bytes | 445.00 KiB/s, done.
    Total 6 (delta 3), reused 0 (delta 0)
    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


  • 相关阅读:
    Java Static Import的用法
    Java EE官方文档汇总
    JDK/Java SE官方文档汇总
    IntelliJ IDEA删除所有断点
    Java基础教程:tutorialspoint-junit
    Spring MVC中@RequestParam/@RequestBody/@RequestHeader的用法收集(转)
    SpringBoot中@EnableAutoConfiguration注解用法收集
    Spring Cloud ZooKeeper集成Feign的坑3,程序Run模式运行没事,Debug模式下报错
    Java中HashMap的初始容量设置
    win7下scheme环境配置
  • 原文地址:https://www.cnblogs.com/gyfluck/p/9599182.html
Copyright © 2011-2022 走看看