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>
总之呢, 多个remote 的时候,特别是有fork,有主干,那么最好先pull。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .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 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义