+2 votes
1 view
in DevOps and Agile by (20k points)

I "accidentally" pushed a commit to GitHub.

Is it possible to remove this commit?

I want to revert my GitHub repository as it was before this commit.

1 Answer

+1 vote
by (28.4k points)
edited by

Let's say you've performed two committed and pushed them by mistake.Now you found out that commit XXXXX was before those wrongful commits. Then force push the last perfect commit as the new master. 

Step 1: Find out the commit you want to revert using the following command:

git log

Say, XXXX is the commit before the wrongly pushed commit. 

Step 2:  Force push the commit as the master

git push origin +XXXXX:master

Here, + is used for force push

For more information please go through the following tutorial to get more info about git:

 

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...