Last Updated: February 25, 2016
·
461
· klj613

Recovering from master being rewritten

If your local master was up to date to what origin had BEFORE master was rewritten:

git fetch origin

git checkout feature-x
git rebase master --onto origin/master

or

git rebase master feature-x --onto origin/master

If something was/is wrong with your local master (or it was already updated to origin/master):

git fetch

git rebase origin/master -i

Whilst in interactive mode remove any commits which are already in origin/master (reason they come up is different SHAs).

If you don't remove the duplicates then you might get conflicts, which after you have resolved them git rebase --continue doesn't work. This is because the commit your trying to add doesn't actually change anything. To get around this you simply git rebase --skip.