Github is web based hosting service for software development. Sometimes you ran into a situation in which you accidentally pushed a commit to Github which you want to to remove. Now you want to revert your Github repository as it was before that commit. Hence you’ve to delete that commit.
However there are some ways from which you can remove pushed commits from Github page. This situation mainly occur because you fully understand Octopress on GitHub. In my case I was not fully understand about GitHub API and make this mistake because I don’t know how to use Github properly.
How To Remove Pushed Commits on GitHub
Usually when you pushed a commit its goes through Master brand into Github server which generate the specific file deploy directory. which automatically pushed your commit in Github.
Step 1 :
Firstly locate the commit you want to revert (git log)
Step 2 :
Remove the commit from the local repository using (git push origin +75896:master). While +75896 is the wrong push commit.
Step 3 :
The ( + ) was for force push.
The second Option To Remove Commits
There is also another way to remove commits from Github that not full safe. To remove commits you can use Git Reset to undo things.
The force push
(git reset 7f6d03 –hard)
(git push origin -f )
(git push -f origin HEAD^:master)