Remove certain commit from branch on github

First with

$ git log

check in which position is the commit you want to remove.

Then you are going to use rebase and depends on the position your commit is, you will rebase HEAD~3 note that there is a number that is going to bring me the last 3 commits.

$ git rebase -i HEAD~3

Then this is going to open your editor and display a list of those 3 commits then remove from that list the commit you want to erase.

save changes

Safty check, use git log to corroborate that your changes were made up.

$ git log

the commit you removed should not appear on git logs.

Then as the last thing to do, you need to push your changes to your branch on github.

git push origin -f YOUR_NAME_BRANCH  

And there you go.

Victor Velazquez

Coder, Musician, Startups, Passionate Dancer & Life Lover. Director of Engineering at MagmaLabs, Co-founder of Web Dev Talks, Co-founder of Voltaire, Co-founder of Paqkit, Ex-co-founder of Zaznova.

Subscribe to The zazvick's blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!