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


    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。


    版权声明
    本文原创发表于 博客园,作者为 阿K .     本文欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则视为侵权。
    欢迎关注本人微信公众号:觉醒的码农,或者扫码进群:

  • 相关阅读:
    柯乐义关灯效果
    柯乐义高级弹出菜单(可以有三级菜单)
    柯乐义图片压缩类
    JS在textarea光标处插入文本
    EntityFramework实例
    【Java学习笔记】读取URL
    【Java学习笔记】编码学习
    【Java学习笔记】本地化
    【Java学习笔记】操作JAR文件
    【Java6学习笔记】多线程编程中使用volatile保障原子性
  • 原文地址:https://www.cnblogs.com/FlyAway2013/p/15558213.html
Copyright © 2020-2023  润新知