在使用Git Push代码到数据仓库时,提示如下错误:

[remote rejected] master -> master (branch is currently checked out)
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'.
To git@192.168.1.X:/var/git.server/.../web
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'git@192.168.1.X:/var/git.server/.../web'

这是由于git默认拒绝了push操作,需要进行设置,修改.git/config添加如下代码:

[receive]
    denyCurrentBranch = ignore

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

如果使用了git init初始化,则远程仓库的目录下,也包含work tree,当本地仓库向远程仓库push时,   如果远程仓库正在push的分支上(如果当时不在push的分支,就没有问题), 那么push后的结果不会反应在work tree上,  也即在远程仓库的目录下对应的文件还是之前的内容,必须得使用git reset --hard才能看到push后的内容.

Linux] Git: push 出错的解决 master -> master (branch is currently checked out)的更多相关文章

  1. git push出错的解决办法

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

  2. git push后出现错误 ![rejected] master -> master(non-fast-forward) error:failed to push some refs to 'XXX'

    本地创建了一个project并在GitHub上创建了一个仓库,想要将本地的仓库链接到远程仓库我用的是如下方法:git init    //初始化本地仓库git remote add origin XX ...

  3. Git push时报错 ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to......

    今天在使用Git回退到之前某个版本的代码时,进行push时出现如下错误: ! [remote rejected] master -> master (pre-receive hook decli ...

  4. git push时提示"fatal: The current branch master has no..."

    git push到远程仓库时提示:fatal: The current branch master2 has no upstream branch. To push the current branc ...

  5. git push remote error解决办法

    通常在用git clone了remote端(服务器)的git仓库后,再进行了自己一系列修改后,会将自己测试后稳定的状态push到remote端,以更新源仓库,使 其他人在pull的时候得到自己的修改. ...

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

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

  7. Git push 出错 [The remote end hung up unexpectedly] - 简书

    one day,my teamate using git push and occured this error. $ git push Counting objects: 2332669, done ...

  8. Linux 安装OpenSSL出错的解决方法

    以前编译php没有 –with–openssl 现在要使用到 openssl ,phpinze扩展安装,但是在make时候报错 今天找这个在网上找了大半天,最后总结应该是php版本本身的问题,错误是p ...

  9. git将本地内容传送到远程仓库出现![rejected] master -> master (fetch first)错误

    问题:使用git push -u 远程库名 master 命令将本地提交的内容传到git远程库时出现错误: 命令: git push -u origin master 出现错误: To https:/ ...

随机推荐

  1. microsoft help viewer 收藏夹功能

    平时重装系统比较多,重装后,microsoft help viewer 2.0里面的收藏就丢失了,要恢复以前的收藏,可以直接在C:\Users\ZR\AppData\Local\Microsoft\H ...

  2. windows Driver 查询指定键值

    NTSTATUS status; HANDLE hKey = NULL; OBJECT_ATTRIBUTES oa; UNICODE_STRING strPath = RTL_CONSTANT_STR ...

  3. Charles中windows版本解决response乱码问题

    实际上三种,目前写了两种,加了之后有的不显示乱码,但是有的还是显示,第三种搜索结果是安装证书,但是本人安装后证书后未受到信任,所以暂时不知是否能够成功 1,在charles.ini中,手动增加一个vm ...

  4. Resource interpreted as Stylesheet but transferred with MIME || DevTools failed to parse SourceMap:

    最近在学SpringBoot,在整合Thymeleaf的时候,配置拦截器.教学上讲SpringBoot已经做好了静态资源映射,所以不需要特地去做排除拦截 以下代码就是我在做登录拦截的时候配置的拦截. ...

  5. Alpha版(内部测试版发布)

    使用说明: 使用环境:android 5.0以上 使用流程: 1.注册与登陆 可以通过游客和用户两个模式登陆 用户模式:进入后会有模拟位置图,每一环代表不同的距离 底部菜单栏表示不同的功能,消息栏可以 ...

  6. stm32h7 开发板学习

    按键和 IO 之间连接一个 1K 电阻,可以防止当 IO 被配置为高电平输出的时候,按下按键,导致 VDD 和 GND 直接连通.

  7. 使用openssl做CA服务器,并且生成证书。

    [root@22 conf.d]# openssl genrsa -out /etc/pki/CA/private/cakey.pem 4096  #ca私钥 [root@22 conf.d]# op ...

  8. 2020PHP面试-SQL篇

    一.乐观锁和悲观锁 1.悲观锁是指假设并发更新会发生冲突,不管冲突是否会发生,都会使用锁机制. 优点: 完全保证数据安全. 缺点:锁机制会有额外开销,并发度降低. 可能会产生死锁. 2. 乐观锁是指假 ...

  9. VMware HA、FT、VADP、SRM、VR、vMotion

    VMware提供了一系列保护虚拟机可用性的功能:HA.FT.VADP.SRM以及vMotion.实现最大化虚拟系统可用性的关键在于了解公司策略以及可利用的技术能够使用哪些特性.下面简要介绍一下在特定的 ...

  10. jQuery选择器全解析

    1. 基本选择器 1.1 id选择器:$(#id) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...