【git】Updates were rejected because the tip of your current branch is behind

一、问题

$ git push
To xxxxxx:test/cloud_platform_test.git
 ! [rejected]        master -> master (non-fast-forward)
error: 无法推送一些引用到 'xxxxxxx:test/cloud_platform_test.git'
提示:Updates were rejected because the tip of your current branch is behind
提示:its remote counterpart. If you want to integrate the remote changes,
提示:use 'git pull' before pushing again.
提示:See the 'Note about fast-forwards' in 'git push --help' for details.

 

二、解决办法

11:13:44.345: [cloud_platform_test] git -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/master:master
To xxxxxx:test/cloud_platform_test.git
error: failed to push some refs to 'xxxxx:test/cloud_platform_test.git'
!    refs/heads/master:refs/heads/master    [rejected] (non-fast-forward)hint: Updates were rejected because the tip of your current branch is behind

Done
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
11:14:13.172: [cloud_platform_test] git -c core.quotepath=false -c log.showSignature=false fetch origin --recurse-submodules=no --progress --prune
11:14:14.368: [cloud_platform_test] git -c core.quotepath=false -c log.showSignature=false -c core.commentChar= rebase origin/master
Rebasing (1/1)
Successfully rebased and updated refs/heads/master.
11:14:14.433: [cloud_platform_test] git -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/master:master
Enumerating objects: 10, done.
Counting objects:  10% (1/10)
Counting objects:  20% (2/10)
Counting objects:  30% (3/10)
Counting objects:  40% (4/10)
Counting objects:  50% (5/10)
Counting objects:  60% (6/10)
Counting objects:  70% (7/10)
Counting objects:  80% (8/10)
Counting objects:  90% (9/10)
Counting objects: 100% (10/10)
Counting objects: 100% (10/10), done.
Delta compression using up to 16 threads
Compressing objects:  16% (1/6)
Compressing objects:  33% (2/6)
Compressing objects:  50% (3/6)
Compressing objects:  66% (4/6)
Compressing objects:  83% (5/6)
Compressing objects: 100% (6/6)
Compressing objects: 100% (6/6), done.
Writing objects:  14% (1/7)
Writing objects:  28% (2/7)
Writing objects:  42% (3/7)
Writing objects:  57% (4/7)
Writing objects:  71% (5/7)
Writing objects: 100% (7/7)
Writing objects: 100% (7/7), 9.75 KiB | 1.63 MiB/s, done.
Total 7 (delta 3), reused 0 (delta 0), pack-reused 0
To xxxxxx:test/cloud_platform_test.git
     refs/heads/master:refs/heads/master    768cdf3..383e245
Done

总结一下

git -c core.quotepath=false -c log.showSignature=false fetch origin --recurse-submodules=no --progress --prune
git -c core.quotepath=false -c log.showSignature=false -c core.commentChar= rebase origin/master
git -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/master:master

简化一下

git fetch origin
git rebase origin/master
git push

 

posted @ 2025-04-29 11:26  代码诠释的世界  阅读(109)  评论(0)    收藏  举报