问题
Normally, Mercurial will abort if I have a dirty working copy when I try to import a patch:
$ hg import x.patch
abort: outstanding uncommitted changes
Is it possible to import it anyway?
回答1:
With Mercurial 1.9, you can use hg import --bypass
to apply a patch without touching the working copy. The patch will be applied on the working copy parent revision by default. Use the --exact
flag to apply the patch onto the changeset mentioned in the patch header instead.
回答2:
If you are using TortoiseHg, you can use Repository > Import
, then specify that the patch should be imported to Shelf
and finally in the shelf, move the changes to the dirty working repository as you would with any other shelved patch.
I'd love to be able to make right click > "copy patch" in a source repository, then in a cloned repository, right click and "paste patch", hopefully this feature will be implemented in a future version.
来源:https://stackoverflow.com/questions/8521793/can-i-import-a-patch-without-touching-the-working-directory