Git发现git push origin master 报错的解决方法

 更新时间:2017年11月02日 11:29:59   作者:Kangvcar  
本篇文章主要介绍了Git发现git push origin master 报错的解决方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

git push origin master 报错的解决方法,分享给大家,具体如下:

错误提示如下

[root@linux1 php]# git push -u origin master 
To git@github.com:kangvcar/Results-Systems--PHP.git 
 ! [rejected]  master -> master (fetch first) 
error: failed to push some refs to 'git@github.com:kangvcar/Results-Systems--PHP.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing 
hint: to the same ref. You may want to first merge the remote changes (e.g., 
hint: 'git pull') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因

GitHub远程仓库中的README.md文件不在本地仓库中。

解决方案1

我们只需加上 -f 参数即可push成功

[root@linux1 qimo]# git push -f 
warning: push.default is unset; its implicit value is changing in
 Git 2.0 from 'matching' to 'simple'. To squelch this message 
 and maintain the current behavior after the default changes, use: 
 
 git config --global push.default matching 
 
 To squelch this message and adopt the new behavior now, use: 
 
 git config --global push.default simple 
 
 See 'git help config' and search for 'push.default' for further information. 
 (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode 
 'current' instead of 'simple' if you sometimes use older versions of Git) 
 
 Counting objects: 53, done. 
 Compressing objects: 100% (53/53), done. 
 Writing objects: 100% (53/53), 1.35 MiB | 55.00 KiB/s, done. 
 Total 53 (delta 8), reused 0 (delta 0) 
 remote: Resolving deltas: 100% (8/8), done. 
 To git@github.com:kangvcar/Results-Systems--PHP.git 
 + fbe05e8...70b187d master -> master (forced update)

解决方案2

我们只需加上 --rebase 参数然后再重新 push 一次即可

[root@linux1 qimo]# git pull --rebase origin master 
[root@linux1 qimo]# git push -u origin master

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • WordPress网站迁移到新主机防火墙配置

    WordPress网站迁移到新主机防火墙配置

    这篇文章主要为大家介绍了WordPress网站迁移到新主机防火墙配置,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2022-03-03
  • LVS(Linux Virtual Server)Linux 虚拟服务器介绍及配置(负载均衡系统)

    LVS(Linux Virtual Server)Linux 虚拟服务器介绍及配置(负载均衡系统)

    LVS(Linux Virtual Server) 是Unix-like系统中的一个虚拟服务器,是国内贡献给开源组织的一个最优秀的项目之一
    2012-05-05
  • OnZoom基于Apache Hudi的一体架构实践解析

    OnZoom基于Apache Hudi的一体架构实践解析

    这篇文章主要介绍了OnZoom基于Apache Hudi的一体架构实践, 有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步早日升职加薪
    2022-03-03
  • rsync 命令详解与示例

    rsync 命令详解与示例

    rsync 是一个强大的文件同步工具,用于在本地或远程系统之间高效传输和同步文件,它通过仅传输文件的差异部分(增量传输)来节省带宽和时间,是备份、镜像和日常文件同步的常用工具
    2025-05-05
  • MongoDB学习笔记(二) 通过samus驱动实现基本数据操作

    MongoDB学习笔记(二) 通过samus驱动实现基本数据操作

    传统的关系数据库一般由数据库(database)、表(table)、记录(record)三个层次概念组成,MongoDB是由(database)、集合(collection)、文档对象(document)三个层次组成
    2013-07-07
  • 如何快速搭建一个自己的服务器的详细教程(java环境)

    如何快速搭建一个自己的服务器的详细教程(java环境)

    这篇文章主要介绍了如何快速搭建一个自己的服务器的详细教程(java环境),本文通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2020-06-06
  • 数据自动备份解决方案 图文

    数据自动备份解决方案 图文

    直接在网盘内建立项目、文件进行稿写操作很可能会与网盘数据不同步导致数据丢失完整性,对文件造成损坏,所以这种方式是不可取的
    2011-12-12
  • hadoop重新格式化HDFS步骤解析

    hadoop重新格式化HDFS步骤解析

    这篇文章主要介绍了hadoop重新格式化HDFS步骤解析,由于此方法需要将HDFS中数据全部清除,用者需注意。
    2017-10-10
  • 一文让你知道服务器是什么

    一文让你知道服务器是什么

    服务器指的是网络环境下能为其它客户机(如PC机、智能手机、ATM等终端甚至是火车系统等大型设备)提供某种服务的专用计算机,它比普通计算机运行更快、负载更高、价格更贵,服务器具有高速的CPU运算能力、长时间的可靠运行、强大的I/O外部数据吞吐能力以及更好的扩展性
    2023-08-08
  • Cisco网络防火墙配置方法

    Cisco网络防火墙配置方法

    这篇文章主要介绍了Cisco网络防火墙配置方法,需要的朋友可以参考下
    2016-04-04

最新评论