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


  • 相关阅读:
    SQL 2008R2问题:用户、组或角色'XXX'在当前数据库中已存在?
    修改sqlserver 2008 R2 实例名称
    keepalived vip做网关
    Django(HttpResponse、render,、redirect)的用法
    Linux脚本中$#、$0、$1、$@、$*、$$、$?
    linux定时删除历史日志文件实现方式--shell脚本
    Long转换为date
    java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener
    2016年新年伊始
    linux下环境搭建
  • 原文地址:https://www.cnblogs.com/gyfluck/p/9599182.html
Copyright © 2011-2022 走看看