I did some code changes in Visual Studio from the main branch and tried to commit the changes in a new branch in TortoiseHG, but apparently I accidentally committed the corrections to the main branch. I have not pushed the changes to the remote repository but if I try to do a "Backout" on the change I get the error message "Cannot backout change on a different branch", even though it clearly states that the changes have been committed to the main branch.
Does anyone know why I get this error message and how I can move the changes into the correct branch?
As long as your changes are not yet pushed anywhere else there are two options.
a) Use hg rebase to move one changeset and all of its descendents on top of another changeset:
hg rebase -s FIRST_CHANGESET_TO_MOVE -d DESTINATION
b) The less recommended way, which only works if you want to undo ONE commit and haven't pulled or committed anything since, is to use hg rollback. But even in those cases hg rebase seems like the easier thing to use.
Firstly you don't want to Backout as that is for undoing pushed / published changes.
There are multiple ways to do this fix this:
Repository -> Rollback/Undo
This will undo you last commit and leave your working directly with the uncommitted changed. You can then recommit making sure to select the new branch name.
If for some reason Rollback/Undo doesn't work:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With