Mercurial, commit changes in working copy to another branch

2k Views Asked by At

I forgot to switch my working copy back to the correct branch and made some changes.

How can I commit the current changes (but not all other changes in the current branch) to my original branch?

2

There are 2 best solutions below

2
Lazy Badger On BEST ANSWER
  • Shelve extension allow you to store WIP, get clean working dir, update to needed branch, release shelve
  • MQ exension (somehow overkill) allow to do the same thing, as shelve
  • At last, you can commit into wrong branch and rebase this changeset to the correct parent, using Rebase extension
1
Vince On

If I understand correctly, you have uncommitted changes that need to be on top of another branch.

My prefered way is to use the shelf functionality to save all your changes, update to the correct branch, and then un-shelf your changes back on the proper branch.

To do it on the command line, save the result of hg diff in a patch file, then update to the other branch and hg import <patch>.

Finally, just commit your changeset, as you wanted.