! [rejected] develop -> develop (non-fast-forward) error: failed to push some refs to...

当尝试推送Git的develop分支并遇到非快进合并错误时,这意味着本地分支落后于远程分支。解决方法包括强制推送(风险较高)、回退并拉取最新代码,或者使用stash保存本地改动、拉取更新后再应用。建议先确保代码无误,再选择合适的方法避免丢失工作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

git提交常见错误1:

$ git push origin develop 
To github.azc.ext.hp.com:xun-chen/uservice.git
 ! [rejected]          develop -> develop (non-fast-forward)
error: failed to push some refs to 'github.azc.ext.hp.com:xun-chen/uservice.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. 

背景:

描述:当用develop向远程提交代码并merge后,且merge过程中你又有别的改动,当你再提交时便会出现这个问题,主要原因是因为分支的变动,
你没有指向当前最新的head(可查看git log命令),所以你需要先跟新本地及fork厂库的代码,再改代码。

解决方法一:

(你舍不得你修改的,那么你觉得万无一失的情况下,用你
在本地拉取的远程最新代码去覆盖fork厂库也是可以的。)(比较快,但有风险)

git push -f

解决方法二:

将修改的备份,然后回撤至初始提交,然后拉取代码,更新分支及fork仓库,再将修改的部分放到代码里面去(比较笨,但实用)

解决方法三:

同过stash save命令将本地未提交修改先暂存,再拉取更新分支。或切换分支并跟新代码,然后然切换后的分支指向最新代码节点。再将stash pop到切换的分支上,并提交(比较稳当)
(欢迎大佬多多指教)

remote: Enumerating objects: 6, done. remote: Counting objects: 16% (1/6) remote: Counting objects: 33% (2/6) remote: Counting objects: 50% (3/6) remote: Counting objects: 66% (4/6) remote: Counting objects: 83% (5/6) remote: Counting objects: 100% (6/6) remote: Counting objects: 100% (6/6), done. remote: Compressing objects: 20% (1/5) remote: Compressing objects: 40% (2/5) remote: Compressing objects: 60% (3/5) remote: Compressing objects: 80% (4/5) remote: Compressing objects: 100% (5/5) remote: Compressing objects: 100% (5/5), done. remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0) From https://gitee.com/zhang-liucheng/jqcx * [new branch] develop -> origin/develop * [new branch] master -> origin/master 15:12:58.584: [SupportCheckingTool_ParaDoc] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false fetch origin --recurse-submodules=no --progress --prune 15:13:02.013: [SupportCheckingTool_ParaDoc] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false merge origin/master --no-stat -v fatal: refusing to merge unrelated histories 15:15:23.775: [SupportCheckingTool_ParaDoc] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/master:master error: failed to push some refs to 'https://gitee.com/zhang-liucheng/jqcx.git' To https://gitee.com/zhang-liucheng/jqcx.git ! refs/heads/master:refs/heads/master [rejected] (non-fast-forward)hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. If you want to integrate the remote changes, Done hint: use 'git pull' before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
03-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值