Search code examples
mercurialrebasecherry-pick

Mercurial - `hg graft` with custom destination?


Is there a way to graft a commit onto somewhere other than the current revision?

The documentation makes it sound like there isn't:

hg graft [OPTION]... [-r REV]... REV...

copy commits from a different location

And I don't see any parameters that can be passed to hg graft to do so. I'm surprised though that hg rebase allows this with the -d flag, but hg graft doesn't. Just like how sometimes I want to rebase a branch to somewhere other than the current revision, sometimes I want to graft a branch to somewhere other than the current revision.


Solution

  • You can use the rebase extension to achieve this. Do hg rebase -r <rev> -d <dest> --keep to rebase the onto while keeping the old rev.