Mercurial: copying ONE file and its history to another repository

后端 未结 2 707
失恋的感觉
失恋的感觉 2020-12-07 15:51

I\'m wondering if I can copy one file and its history from one repository to another, without having to import the whole other repository.

2条回答
  •  轮回少年
    2020-12-07 16:16

    You can use the ConvertExtension to export just that one file from the first repository into a new temporary repository, then use hg pull -f to import the new repository into the target repository.

    Create a filemap for the ConvertExtension with the single line:

    include path/to/file
    

    Then use:

    hg convert path/to/original path/to/temporary --filemap filemap
    

    to create the temporary repository. Next, in the target repository, do:

    hg pull -f path/to/temporary
    

    to pull in that file with its history. This will create a new head, so use hg merge to merge it with the head in your target repository.

提交回复
热议问题