Git推送错误:"! [拒绝]开发 - >发展(非快进)"

时间:2014-06-25 17:18:55

标签: git bitbucket

我有一份提交列表(最新的):

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.

我试图拉动变化,但得到了smth。拉完后很奇怪:

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

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

1 个答案:

答案 0 :(得分:5)

您应该可以强制推送(假设您已将bitbucket设置为远程“原点”):

git checkout develop
git push -f origin develop

请注意,在执行此操作之前,您可能需要重置本地开发分支(如果它现在指向您的拉/合并提交):

git checkout develop
git reset --hard new_hash_of_abcd3
git push -f origin develop
相关问题