I’ve encountered a problem in my Mercurial workflow when experimenting with implementing a certain feature. I was trying three different approaches to implementing the feature by commiting each update followed by updating to the previous changeset – so I end up with three different branches.
Once I have chosen one of the branches to be the “correct” implementation of the feature, I want to remove the other branches so that I don’t have multiple heads. How do I do this in a simple way? I ended up merging the three branches together which was pointless because I only ever wanted the code from one branch.
In addition to
hg stripfrom the mq extension, you can simply use the standard clone command:to get a clone in
../prunedthat holds only the good head (and all its ancestors). This is the safe, built-in way to prune things in Mercurial and it has the advantage that you still have both repositories intact after the command. So if you make a mistake, then just delete the../prunedclone.