本地分支从Origin分支分离出来,但我不想合并/ fastforward [英] Local branch diverged from Origin branch but I do not want to merge/fastforward
问题描述
git reset --hard< sha>
的提交。 我已经解决了问题并在本地提交。现在我想推到Origin,但是我不能这样做,因为我的分支是由5次提交(导致问题)和1次提交(修复提交)提前后面的Origin。即。分支分支。
我不想合并来自Origin的任何更改。我怎样才能将Origin的头部设置为我的本地提交的头部,而不需要合并到我的本地分支中的分离提交?
谢谢!
干净的方式(保留历史记录) 在您当前的提交中使用本地bugfix分支 肮脏的方式(丢弃历史记录,discombobulate在远程分支上工作的任何人) Several commits have been pushed to the origin branch. These commits contain code that caused a problem. In order to fix the problem I did a I have since fixed the problem and committed locally. Now I want to push to Origin but I cannot because my branch is behind Origin by 5 commits (that caused the problem) and ahead by 1 commit (the fixing commit). ie. diverged branches. I do not want to merge in any of the changes from Origin. How can I set the head of Origin to that of my Local commit and without merging in the breaking commits into my Local branch? Thanks! The clean way (that preserves history) The dirty way (discards history, discombobulates anyone else working on the remote branch)
这篇关于本地分支从Origin分支分离出来,但我不想合并/ fastforward的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
git push -f
(仔细检查你是否有正确的选项和放大器) refspec),并希望没有其他人的远程分支历史发生变化。
git reset --hard <sha>
to the commit before the problem started.
git revert
the bad commits (everything between the last good sha where you forked, and the remote HEAD) ... this removes the unwanted changes while preserving all the history
git push -f
(double-check you have the right options & refspec) and hope no-one else has had their remote branch history change underneath them