Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial: Fix a borked history

Tags:

mercurial

So working on a project recently (by myself - no other developers), I somehow managed to seriously bork the history with some (apparently) bad merges from cloned repositories.

What I would like to do - need to do - is fix this by just deleting the last 8 commits (according to hg glog)

Yes, I have made a few changes to the code after the borking began, however, only a few tweaks here or there - nothing I can't fix fresh from memory.

How can I get rid of the last 8 commits and start over from where I messed up?

like image 498
Austin Hyde Avatar asked Jul 22 '10 14:07

Austin Hyde


1 Answers

Make a clone of your repository - when you do this, you can specify the last commit that should be cloned.

So, if your repository has 100 changesets and you want to get rid of changesets 93 to 100, just do this:

hg clone -r 92 BadRepository CleanRepository

--> the CleanRepository will only contain changesets 1 to 92.

If you use TortoiseHG, you can do the same in the Clone dialog (there is a textbox "Clone to revision:")

like image 200
Christian Specht Avatar answered Oct 16 '22 16:10

Christian Specht