git push错误failed to push some refs to的解决
问题说明
当我们在github版本库中发现一个问题后,你在github上对它进行了在线的修改;或者你直接在github上的某个库中添加readme文件或者其他什么文件,但是没有对本地库进行同步。这个时候当你再次有commit想要从本地库提交到远程的github库中时就会出现push失败的问题。
如下图所示
我在github库中对某个文件进行了在线的编辑,并且没有同步到本地库,之后我在本地库添加了文件test.txt,并想提交到github,出现以下错误:error:failed to push some refs to。

解决方案
这个问题是因为远程库与本地库不一致造成的,那么我们把远程库同步到本地库就可以了。
使用指令
注意:此处我使用的是master分支,请根据自己的开发分支更换分支。
git pull --rebase origin master
- 1
1
这条指令的意思是把远程库中的更新合并到本地库中,–rebase的作用是取消掉本地库中刚刚的commit,并把他们接到更新后的版本库之中。

下面我用图形象的解释下错误情况的发生和解决

git pull --rebase origin master意为先取消commit记录,并且把它们临时 保存为补丁(patch)(这些补丁放到".git/rebase"目录中),之后同步远程库到本地,最后合并补丁到本地库之中。

接下来就可以把本地库push到远程库当中了。

原文链接:https://blog.csdn.net/qq_44721831/article/details/106699135
git push错误failed to push some refs to的解决的更多相关文章
- 解决:git push error: failed to push some refs to
出现错误的原因是github中的README.md文件不在本地代码目录中. 也就是说我们需要先将远程代码库中的任何文件先pull到本地代码库中,才能push新的代码到github代码库中. 使用如下命 ...
- git报错failed to push some refs to 'git@github.com:Markprint/github.git'
这个不知名小错误用了我两天的空余时间mmp 就是这里报的错 输入 git push origin master -f 解释为: 远程分支上存在本地分支中不存在的提交,往往是多人协作开发过程中遇到 ...
- git push 时 failed to push some refs 的解决方案
我们在利用 GIt 上传代码的时候,往往会遇到这样一个问题,导致我们的代码没有办法正常上传到仓库中 造成这个问题的原因其实很简单,就是因为远程仓库和本地库不一致. 基于这样的一个问题,解决办法自然也就 ...
- git/github error: failed to push some refs to 'https://github.com/shenhaha/cloudletter.git'
git 提交代码到github上报如下错误 报错分析: 解决方法: 关闭这两个设置 再次提交代码 success
- git push 错误,回滚 push操作
作者:故事我忘了¢个人微信公众号:程序猿的月光宝盒 0.记一次使用git push后,覆盖了同事代码的糗事 前言: 都在WebStorm中操作,Idea或者PyCharm同理 为了高度还原尴尬 ...
- Git本地分支版本号过低导致的push错误 error: failed to push some refs to ... 及兴许amend
今天在用git的时候遇到了一个问题.在想远程分支push的时候,出现了以下的错误: ! [remote rejected] master -> refs/for/master (change 1 ...
- git 错误error: failed to push some refs to
今天使用VSCODE 学习node.js, 想在git上push代码 于是在git上建立了一个私有的长裤, 连接后push代码时提示如下错误: error: failed to push some ...
- Git错误:error:failed to push some refs to 'git@gitee.com:name/project.git'
大家在通过本地仓库上传文件到远程仓库时,会报出 error:failed to push some refs to 'git@gitee.com:name/project.git' 的错误. 解决方法 ...
- 错误:error: failed to push some refs to 'https://github.com/pzq7025/KG.git'的解决办法
一.问题在进行[git push orgin master]的时候出现如下错误 ! [rejected] master -> master (non-fast-forward) error: f ...
- git push 时发生错误 error: src refspec master does not match any. error: failed to push some refs to
很多相关解决办法都是最后要 push 到远端的 master 上,但很多其实要求不能把个人的修改内容直接 push 到 master 主分支. 因此,当我想将本地 feature/work1 分支的修 ...
随机推荐
- maven加载本地的jar包
方式1 ,通过scope = system的方式加载 <dependency> <groupId>com.sun.jna</groupId> <artifac ...
- ObjectARX2020向导创建项目失败,一直显示创建窗口原因
安装了好多次,查了好多资料,发现是需要将向导的msi文件以管理员权限运行,可以参考下面的链接 https://www.dawnnote.com/237.html
- sqlsugar 更新某列数据 UpdateColumns 与SetColumns 使用区别
第一种方式 UpdateColumns public int updateLogPath(int TeamID, string logoPath) { Team t = new Team(); t.T ...
- mount无响应
mount -t xfs /dev/sdb /data 挂载不成功,且命令无任何回显. dmesg 查看到有报错 tailf /var/log/messages -n 100 systemctl da ...
- EasyExcel工具使用
pom文件: <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel< ...
- 解决idea不能自动下载maven配置文件pom.xml下的jar包依赖的问题
表现:无法下载pom配置文件中的依赖包,或只能下载少数包,各项配置都正确的情况 理由未知: 百度了很长一段时间,网上给出比较精准的解决之一是 setting>>maven>>去 ...
- [BOM]实现页面loading效果,在图片资源加载完之前显示loading
使用到jquery. 判断整个页面是否加载完: // 这是根据js判断,页面加载完毕就显示 window.onload = function () { // console.log('load com ...
- The operation was rejected by your operating system.
我在新项目开启的时候使用npm install来初始化前端代码的开发环境 但是遇到一个问题,一直报: The operation was rejected by your operating syst ...
- Mybatis实现树状结构查询
1.实体类 @Data public class CourseChapterVO implements Serializable { private static final long serialV ...
- jemeter批量测试
一.使用badboy录制脚本 1.下载安装badboy(参看:https://blog.csdn.net/qq_36396763/article/details/78803381),成功标志如下: 2 ...