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

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

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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 2021-11-16 08:54  CanntBelieve  阅读(2668)  评论(0编辑  收藏  举报