场景

$ git push
To https://github.com/XXX/XXX
! [rejected] dev -> dev (non-fast-forward)
error: failed to push some refs to 'https://github.com/XXX/XXX'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因

远端冲突

解决方案

推荐方案3

因为merge会新建commit, 让网络图错综复杂, 十分难观察

  1. git push --force

    暴力更新代码, 这样会丢失远端的一些提交(或者代码)

  2. git pull ( fetch + merge )

    本地取远端修改, 然后合并

  3. git pull -- rebase ( fetch + rebase )

    本地取远端修改, 然后变基

merge 与 rebase 的区别

  1. merge 是新建一个commit, 在新的commit中, 在两个分支上各取最近祖先至今的修改, 合并, 移动head到最新分支上.

  2. rebase是不新建commit, 首先剪切本分支最近祖先至今的修改, 然后移动head到另一分支. 在另一个分支上, 粘贴刚才的修改, 移动head到最新修改上.

具体详见https://www.jianshu.com/p/c17472d704a0

[git] Updates were rejected because the tip of your current branch is behind its remote counterpart.的更多相关文章

  1. Git 报错:Updates were rejected because the tip of your current branch is behind

    刚开始学习 git 命令,发现会出现很多的错误,所以就总结下出现的错误,以此来加深理解和掌握吧! 环境:在本地库操作了一系列的 add 和 commit 操作后,想把本地仓库推送到远端,但是发生以下错 ...

  2. (转)Updates were rejected because the tip of your current branch is behind

    刚创建的github版本库,在push代码时出错: $ git push -u origin masterTo git@github.com:******/Demo.git ! [rejected] ...

  3. 01_第一次如何上传GitHub(转)Updates were rejected because the tip of your current branch is behind

    https://www.cnblogs.com/code-changeworld/p/4779145.html 刚创建的github版本库,在push代码时出错: $ git push -u orig ...

  4. git push时报错:Updates were rejected because the tip of your current branch is behind

    出现这样的问题是由于:自己当前版本低于远程仓库版本 有如下几种解决方法: 1.使用强制push的方法: git push -u origin master -f 这样会使远程修改丢失,一般是不可取的, ...

  5. git提交报错:Updates were rejected because the tip of your current branch is behind

    提交代码push时报错:上网查询了一下解决办法有很多种,1.使用强制push的方法:(上网查询说这种会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候.) git push -u origin ...

  6. git提交时报错:Updates were rejected because the tip of your current branch is behind

    有如下3种解决方法: 1.使用强制push的方法:git push -u origin master -f这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候. 2.push前先将远程rep ...

  7. Updates were rejected because the tip of your current branch is behind 问题出现解决方案

    提供如下几种方式: 1.使用强制push的方法(多人协作时不可取): git push -u origin master -f 2.push前先将远程repository修改pull下来 git pu ...

  8. git push ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/Operater9/guest' hint: Updates were rejected because the tip of your current bra

    推送本地代码到github报错 git push报错 ! [rejected] master -> master (non-fast-forward) error: failed to push ...

  9. Git出现There is no tracking information for the current branch提示的解决办法

    参考:https://blog.csdn.net/sinat_36246371/article/details/79738782 在执行git pull的时候,提示当前branch没有跟踪信息: Th ...

随机推荐

  1. Android-Glide使用

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/Li_Qing_Xue/article/details/78919499 图片加载很是重要,我也对比过 ...

  2. 用hugo搭建个人博客

    这几天研究了用hugo搭建个人博客. 简单的整理了一下. 1.安装hugo(windows 请查看官网介绍 https://gohugo.io/getting-started/installing/) ...

  3. Django博客系统

    零.创建项目及配置 一.编写 Model 层的代码 二.配置 admin 页面 三.根据需求定制 admin

  4. Jmeter联机负载时报错: connection refused to host localhost,nested exception is:java.net ConnectException:Connection refused:connect

    Jmeter联机负载时报错: connection refused to host localhost,nested exception  is:java.net ConnectException:C ...

  5. php版本:实现过滤掉广告、色情、政治相关的敏感词

    现在网络上还是很乱,尤其充斥着各种广告.色情.政治相关的内容,很明显这是不符合我们国家的法律的,所以为了一个产品能够健康长久的活下去,最好还是采用一定的策略过滤或者提醒用户不要发这种内容.不过说起来容 ...

  6. 小马哥-Java 微服务实践 - Spring Boot 系列-01Java 微服务实践 - Spring Boot 系列(一)初体验

    课程github地址 https://github.com/mercyblitz/segmentfault-lessons 传统的web应用架构.微服务是一种架构.不限定什么语言 单体应用和微服务的对 ...

  7. Qt编写自定义控件16-魔法老鼠

    前言 五一期间一直忙着大屏电子看板软件的开发,没有再去整理控件,今天已经将大屏电子看板的所有子窗口都实现了任意停靠和双击独立再次双击最大化等功能,过阵子有空再写一篇文章介绍其中的技术点.魔法老鼠控件, ...

  8. JAVA 基础编程练习题3 【程序 3 水仙花数】

    3 [程序 3 水仙花数] 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身.例 如:153 是一个"水仙 ...

  9. 代码格式化工具 AStyle

    Astyle是一个用来对C/C++代码进行格式化的工具,在windows或者linux都有对应的版本,下面介绍几个本人比较常用的参数 --style=linux  个人比较喜欢linux风格,即函数的 ...

  10. 虚拟IP技术 ip地址漂移技术

    虚拟IP地址(VIP) 是一个不与特定计算机或一个计算机中的网络接口卡(NIC)相连的IP地址.数据包被发送到这个VIP地址,但是所有的数据还是经过真实的网络接口.VIPs大部分用于连接冗余:一个VI ...