Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
2 views
in DevOps and Agile by (19.4k 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 (27.5k 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:

 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...