OK, I did something stupid.
Now I wanted to issue a pull request, and all of a sudden I see my "check I can commit" commit. I'd rather not like that to appear on the pull request. :)
Can I entirely delete that commit? Can I issue a pull request on a single commit or will it pull all my commits?
I know I can locally git reset --hard HEAD~1
(it's a small fix I could redo quickly) but that only fixes my local repo, not my github (forked) repo.
Lots of options.
The best option is probably to make a new branch and cherry-pick your fix into that branch:
git checkout -b my-fix-branch origin/master
git cherry-pick master
git push -u origin my-fix-branch
then do a pull request from my-fix-branch
on GitHub. (This assumes your working branch is named master
, based off the remote master
; change the branch names as appropriate).
IF nobody has pulled or cloned your fork, you can rewrite history forcefully. Do git rebase -i HEAD~2
and delete the offending commit, then git push --force
. This will break any other repo based on your fork, so do not do this if you suspect anyone else is using your repo.
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