I had a working directory with uncommitted changes and updated to a different branch. Part way through the process of merging all the changed files, I realized that this was not what I wanted to do. Is there a way to recover from this? Is there a way to prevent it from happening again?
Mercurial version 1.8.4
The command executed was hg update default
.
The branch I was in was a child of the default branch. No changes had been made to the default branch since the last merge from default to child.
This is the danger of keeping uncommitted changes in your working copy. Mercurial keeps no record of your working copy changes. You are forced to rely on the files themselves.
It may be possible to recover if you:
- Backup the repo (including the uncommitted changes) so you can try again if needed
hg update <branch you want to be on>
- Carefully review your working copy
This will attempt to merge your working copy changes back into their original branch. However, there is no guarantee that the result will be what you want.
To prevent this in the future, you should use hg update --check
. The --check
option will abort the update if there are uncommitted local changes.
精彩评论