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。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM