So I’m getting started with Git, and I feel like I’m doing something wrong.
I’m trying to roll back to a certain commit on my fork, erasing all history of commits and their changes back to that point. I’ve tried all the stuff I could find suggested around here, and it hasn’t made a difference. I need to make a pull request to a project, but it’s including ALL the commits I’ve made, as well as tons of merge commits. Everyone else that pulls to it don’t have nearly as many commits as myself, so I believe I’m doing something wrong.
The only real reason I want to revert is because there’s a WIP commit I made that I don’t want included on the request, so I’d like to just start clean before that.
Thanks in advance.
Use
git reset --hardto go back as far as you need to, then commit, and finally push the new version up. (You’ll need to use the--forceflag when pushing to overwrite the remote branch.)Try not to make a habit of doing this, though, since if someone had actually done something with the branch you pushed up, overwriting it would leave them with their own problems to resolve.