Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (19.7k points)
My Github has 100 commits in it right now. I need to rollback the repository to commit 80 and remove all the subsequent ones.

Why? This repo is supposed to be for merging from miscellaneous users. A bunch of merges went in as commits from me, due to excessive editing. That was due to a mislabeling of my remote branches, where 3 developers were labelled as each other. I need to reset to that point and then pull forward.

However, git wants me to do a lot of conflict management. Is there a simpler way?

1 Answer

+2 votes
by (62.9k points)

You can use either of the two below mentioned commands:

git reset --hard <old-commit-id> 

git push -f <remote-name> <branch-name>

Note that using this is dangerous in a collaborative environment: as you're rewriting history

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...