I wanted to squash my last 2 commits into one, so did a git rebase
, in following way:
git rebase -i HEAD~2
but due to a typo, what I actually ended up pushing into origin was:
git rebase -i HEAD-3
Now, in the Github Pull Request it shows commit of some other unrelated commit. so basically, I want to remove commit 06674f0
which isn't mine, while keeping fcea5e0
in this PR.
how to fix the mess caused by simple typo?
Even when a commit is squashed , it's still recoverable as the data is in the commit history. Once you know the SHA of the blob you want to recover, use: $ git cat-file -p <SHA> > recover_file.
In order to undo the last commit and discard all changes in the working directory and index, execute the “git reset” command with the “–hard” option and specify the commit before HEAD (“HEAD~1”).
To cancel your membership, login to your account, select the option to “Upgrade or renew your membership” and click the r red “X” under “My subscriptions.” You can also email: [email protected] or call 212-268-4090 for assistance.
Edit: Check your reflog with
git reflog
Pick the commit previous to your first rebase and replace the x with appropriate number below:
Just undo your last rebase and redo it:
git reset --hard HEAD@{x} git rebase -i HEAD~2 .. git push -f origin master
Remove your pull request and issue a new one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With