今天,用git把本地代码推送到远程服务器上时出现错误:

whl@whl-desktop:/work2/recvdsrc$ git push origin master
klha@klha.net's password:
Counting objects: 44, done.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (25/25), 13.10 KiB, done.
Total 25 (delta 18), reused 0 (delta 0)
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 klha@klha.net:/home/klha/recvdata/recvdsrc! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'klha@klha.net:/home/klha/recvdata/recvdsrc'

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

根据提示执行命令解决问题 :

  1. git config receive.denyCurrentBranch ignore

以下参考:

http://blog.sina.com.cn/s/blog_55465b470100s638.html

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

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

git push origin master报错,解决方法相关推荐

  1. git push origin master报错的解决方法 常见git命令(待更新)

    git push origin master报错的解决方法 & 常见git命令(待更新) 参考Git常用命令 文章目录 git push origin master报错的解决方法 & ...

  2. IDEA输入命令git push origin master报错: ! [remote rejected] master - master (hook declined)

    IDEA输入命令git push origin master报错: ! [remote rejected] master -> master (hook declined) error: fai ...

  3. git push origin master报错

    git push origin master报错error: src refspec xxx does not match any / error: failed to push some refs ...

  4. Git - git push origin master 报错的解决方法

    错误提示如下: [root@linux1 php]# git push -u origin master To git@github.com:kangvcar/Results-Systems--PHP ...

  5. git push origin master报错error: src refspec master does not match any || git commit报错nothing to commi

    git需要提交的文件夹内无内容修改导致 建议删除git初始化仓库生成的 .git 文件,然后将文件夹内容转移至其他路径,再次重新初始化提交. 或者, 将要提交的文件内容进行一定修改.

  6. 【码云】git push origin mash 报错:remote: error: GH007: Your push would publish a private email address.

    近期使用码云提交代码到git仓库,发现网上搜索的都是github的解决办法(可以解决的地址:https://blog.csdn.net/qq_24862137/article/details/9440 ...

  7. 使用git bash的git push origin main或git push origin master提交错误

    使用git bash的git push origin main或git push origin master提交错误 首先我安装的是最新版本的git 下载Git 官方地址为:https://git-s ...

  8. git push origin master提交报错解决办法

    使用git push origin master将本地提交推送到远程仓库的时候 遇到了这样的一个报错 wangting@DESKTOP-O81VEVO MINGW64 ~/Desktop/wisdom ...

  9. git push origin master上传资源总是报密码错误,但是密码确实是正确的应该怎么办?

    问题解决: 对Git的版本进行更新,之后再重新启动输入命令即可解决: ①输入命令:git update-git-for-windows,对git进行更新. ②更新git的操作如下: ③成功上传资源界面 ...

最新文章

  1. Data Artisans发布支持ACID事务的流式处理框架Streaming Ledger
  2. datafactory生成mysql数据_测试数据生成工具DataFactory的使用
  3. 区块链带来的价值包括哪些_爱链社区干货:区块链技术为冷链物流带来的了那些价值?...
  4. 【流媒體】jrtplib—VS2010 下RTP开源协议库JRTPLIB3.9.1编译
  5. linux 内核 ntfs,Linux大脑 内核 内核编译(NTFS)
  6. java注释类型_Java 8类型注释
  7. 如何单元测试Java的private方法
  8. 测试m.2固态的软件,Ryzen新平台下M.2固态硬盘性能测试
  9. 将十进制IP转换成二进制IP
  10. 麦子学院深度学习进阶课程题目纲要
  11. hmcl手机版_hmcl启动器整合包安卓版下载-我的世界hmcl启动器安卓版v1.17.10最新版_新绿资源网...
  12. 小学生计算机课程设计,小学版3D建模课程设计
  13. jsDoc的使用文档
  14. 2023中国余热回收利用展览会盛装亮相北京
  15. 018 参数估计之点估计法:矩估计法、最大似然估计
  16. 设置带用户名和密码的telnet登入方式(原创)
  17. 网易猛犸:数据质量漫谈
  18. anaconda图形界面打开方式
  19. 重学Mysql之Mysql8.0修改密码策略
  20. 前谷歌工程师差点因为不知道贝叶斯公式被拒

热门文章

  1. 供应链管理模式下采购管理的根本变化
  2. html5前端Video视频标签和audio音频标签的使用
  3. epic转移游戏_Google对Epic的回应 Android 12将使安装应用商店更加容易
  4. 微信公众号、人脉拓展、运营
  5. 凸轮轴曲轴位置传感器信号波形组合测试-汽车示波器
  6. 保定计算机专业中专学校排名,保定计算机中专技校排名_城铁轨道
  7. PIC16F887 单片机 MAX6675 proteus 基于热电偶的数显温度计 电子消毒柜控制电路设计
  8. 有关经济全球化和我国发展电子商务新思路
  9. golang分布式文件服务器,分享一个用go实现的分布式文件系统:godfs
  10. Ubuntu 18.04 LDAP认证