I have the following situation:
A---B---F---G---H (master)
\
\
C---D---E (experimental)
My problem is that B is a very-very bad thing that shouldn’t have happened on master. It belongs on experimental. However F—G—H are okay. Is there a way to make everything look like this:
A---F'---G'---H' (master)
\
\
B---C---D---E (experiment)
I’ve read about rebase and stuff like that but the biggest problem is that master has been pushed to origin.
git rebase --onto A B masterwill do.Seems you have master already pushed to orgin, if you are certain that it is safe to overwrite master branch of the origin, just do a
git push -fon master branch. Be aware that it may cause other developers have a conflict when they pull from origin.Generally, branch in public repo should stay untouched, which means you can not expect removing commit B from the master, all you can do is fixing the mistake introduced by commit B in a new commit and push it to master again.
If it is possiable to inform your team members about the rebase and you insist to do so, then it is okay for a rewrite, just make sure this won’t happer too often.