Search code examples
gitreset

How to revert a GitHub repo to a certain commit


I've been committing changes inside my GitHub repo. I now want to roll back to a certain commit that I've made sometime ago.

How do I reset my repo so that all the commits I've made, after the one i'd like to go back to, are wiped?

I've found some answers regarding git reset --hard <id> but it's not doing what I want.


Solution

  • You need to "force push" the commit to the repository.

    git reset --hard <id>
    git push --force-with-lease
    

    Please be aware that this wipes data from the remote repository and everyone who already has pulled your repository needs to revert back, too.