Code bits: Fixing a rebase mess

What started being an “easy issue to fix” became a mess rapidly due to my inexperience with GitHub, the issue can be seen [here].

Seems that when I tried to fix some linting errors, I rebased it wrongly and created a divergent branch, that’s why every time I tried to rebase again it did not work as expected.
Seems that this can be fixed using git cherry pick and git push origin --force but as I was unsure how to go with it, and I rather prefer to test it first in my own repository instead of making the commit history of this issue even worst, I decided to take the long way:
git checkout master
git pull // I’m getting the latest changes
git branch -d fix/248 // Deletes the current local branch
git checkout -b fix/248 // Recreates the local branch again
git push origin fix/248 --force // Overwrites the branch by deleting my previous commits to fix/248 and push the latest code into the same Pull Request (as it has the same name and origin) and ignores the warning with --force
This is normally not recommended for one reason: You’ll also overwrite other people commits, but as I was the only person working on this branch, then only my commits are the ones being overwritten.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s