10年 Java程序员,硬核人生!勇往直前,永不退缩!

欢迎围观我的git:https://github.com/R1310328554/spring_security_learn 寻找志同道合的有志于研究技术的朋友,关注本人微信公众号: 觉醒的码农,或Q群 165874185

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  551 随笔 :: 14 文章 :: 86 评论 :: 129万 阅读

git 无法push, 出现: Updates were rejected because the tip of your current branch is behind

复制代码
D:\code\git\mw\umc_file_service>
D:\code\git\mw\umc_file_service>git pull  mine dev
From http://192.169.2.234/luokai/umc_file_service
 * branch            dev        -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
  file/smstxt/manualsmstxt/2021/10/15/1_2_20211015141350944_134851470_10003_1001.txt.md5 logs/all.log.2021-11-12.0 logs/error.log.2021-11-12.0 src/main/java/META-INF/logback.xml

D:\code\git\mw\umc_file_service>git push mine dev
To http://192.169.2.234/luokai/umc_file_service.git
 ! [rejected]        dev -> dev (non-fast-forward)
error: failed to push some refs to 'http://192.169.2.234/luokai/umc_file_service.git'
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.

D:\code\git\mw\umc_file_service>
复制代码

git有错误提示,然后也有修改提示,提示是 先pull再push: 'git pull ...') before pushing again. 但是 我git pull  mine dev 之后,还是不行,后面发现git pull  mine dev 也出现了error, 必须先把那个error 解决, 也就是: Your local changes to the following files would be overwritten by merge... —— 这个是怎么回事呢? 原来是本地有修改没有提交,那么pull 可能会导致冲突,然后可能被覆盖,所以(其实我也不太理解, 冲突的提示是这样的吗? 实际上远程没有人修改logback.xml 文件, logback.xml 是我移动了位置而言 )怎么解决呢? 

先待commit 中的logback.xml 回滚吧,回滚之后就可以正确 git pull  mine dev ,继而可以继续git push mine dev 了 !

 

其实呢,mine  是自己的fork 分支, 不至于我pull 不上去吧, logback.xml 也没有提交,为什么不让push?

。观察到可以看到一个 mine/dev 到dev 的 merger 提交,这种类型提交,之前都是没有发现的,为什么今天出现了? 我猜,大概是 多个人都有进行fork, 后面他们都进行了合并, 然后时间顺序出现了冲突,或者说 git 要求必须先做pull 别人先提交的 内容,自己才能pull。

 

 

某些情况push 是不允许的, 反正就是不能在落后于远程upstream的情况下push。

复制代码
D:\code\git\mw\umc_deploy>git pull ori
Already up to date.

D:\code\git\mw\umc_deploy>git push ori dev
To http://192.169.2.234/umc/umc_deploy.git
 ! [rejected]        dev -> dev (non-fast-forward)
error: failed to push some refs to 'http://192.169.2.234/umc/umc_deploy.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

D:\code\git\mw\umc_deploy>git pull
Already up to date.

D:\code\git\mw\umc_deploy>git push ori dev
To http://192.169.2.234/umc/umc_deploy.git
 ! [rejected]        dev -> dev (non-fast-forward)
error: failed to push some refs to 'http://192.169.2.234/umc/umc_deploy.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
D:\code\git\mw\umc_deploy>git pull ori dev
From http://192.169.2.234/umc/umc_deploy
 * branch            dev        -> FETCH_HEAD
Auto-merging version.txtCONFLICT (content): Merge conflict in version.txt
Automatic merge failed; fix conflicts and then commit the result.

D:\code\git\mw\umc_deploy>
D:\code\git\mw\umc_deploy>
View Code
复制代码

 

总之呢, 多个remote 的时候,特别是有fork,有主干,那么最好先pull。

 

posted on   CanntBelieve  阅读(2936)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示