develop (non-fast-forward)"-6ren"> develop (non-fast-forward)"-我有一个提交列表(最新的在前): abcd4 message abcd3 wrong commit message2 abcd2 wrong commit message1 abcd1 message-6ren">
gpt4 book ai didi

Git 推送错误 : "! [rejected] develop -> develop (non-fast-forward)"

转载 作者:太空狗 更新时间:2023-10-29 14:32:45 27 4
gpt4 key购买 nike

我有一个提交列表(最新的在前):

abcd4 message
abcd3 wrong commit message2
abcd2 wrong commit message1
abcd1 message

我需要更改 abcd2abcd3 的提交消息。我正在按照以下方式进行操作:

rebase -i abcd1

然后,在交互模式下,我将 pick 替换为 reword,更改必要的提交消息并保存更改。这里一切正常。

问题如下:分支已完全推送到 Bitbucket,因此 Bitbucket 上也有错误的提交消息。

我尝试推送更改但出现错误:

 ! [rejected]        develop -> develop (non-fast-forward)
error: failed to push some refs to 'https://login@bitbucket.org/user/repository.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.

我试图提取更改,但没有成功。完成 pull 后很奇怪:

git log --pretty=format:'%h %s' --graph
* ccceeefff Merge branch 'develop' of https://bitbucket.org/user/repository into develop
|\
| * abcd3 wrong commit message2
| * abcd2 wrong commit message1
* | new_hash_of_abcd3 new commit message2
* | new_hash_of_abcd2 new commit message1
|/
* abcd1 message

所以我的问题是:在我的案例中更改消息的正确方法是什么?

最佳答案

您应该能够强制推送(假设您已将 bitbucket 设置为远程“来源”):

git checkout develop
git push -f origin develop

请注意,在您这样做之前,您可能需要重置您的本地开发分支(如果它现在指向您的 pull/merge 提交):

git checkout develop
git reset --hard new_hash_of_abcd3
git push -f origin develop

关于Git 推送错误 : "! [rejected] develop -> develop (non-fast-forward)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24414854/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com