Git Remove unwanted commits from a Pull Request
I assume your origin is your own fork of some project that you want to do a pull request too?
Since you will be changing history (by resetting the head) you will need to push with --force flag. Locate the hash of your last good commit using git log
.
Now run
git reset SHA
This will change your head to that sha and preserve the changes in the files since that last good commit, your index will also be reset.
Now you can change your code and do the commits you want. But you have to do git push --force
since you changed the history of the repository. This means that anyone who forked your repository won't be able to pull changes from you anymore. But you will be able to do a pull request to your upstream.