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 git reset --hard <sha> to the commit before the problem started.
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)
git revertthe bad commits (everything between the last good sha where you forked, and the remote HEAD) … this removes the unwanted changes while preserving all the historyThe dirty way (discards history, discombobulates anyone else working on the remote branch)
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