Merging unrelated repositories

Chris Green cl at isbd.net
Tue Jan 25 21:39:03 UTC 2022


I have a small repository that I would like to merge into my main
repository of scripts.  There are no common files between the two
repositories, the merge is just a convenience to keep everything in
one place (and also to avoid having to decide where new things go!).

Once merged I just want to use one repository, the small one that I
have added/merged can disappear as a separate entity.


I have looked at the Merging Unrelated Repositories page, it has the
following series of commands:-

    hg clone REPO1 work         # Again, pull from both repos...
    cd work
    hg pull -f REPO2
    hg update -C tip            # Now update to the REPO2 tip...
    mkdir lib2                  # And rename everything...
    hg rename * lib2
    hg commit -m "Move everything into lib2 directory."
    hg merge                    # Then simply merge.
    hg commit


So, my main repository lives in directory ~/.cfg.  The directory I want
to merge into my main repository is at ~/.mutt, I'd like its files to
end up in ~/.cfg/mutt.

Thus the above becomes:-

    cd ~/.cfg
    hg pull -f ~/.mutt

... and then I'm a bit confused, if I do:-

    hg update -C tip
    mkdir mutt
    hg rename * lib2
    hg commit -m "move everything from .mutt into ~/.cfg/mutt"
                     
Will I really then have what I want?  It's the 'update' folllowed by
rename that confuses me a bit.

I've just tried it on a copy and it does seem to work OK, can someone
just expand/explain a little please.

-- 
Chris Green


More information about the Mercurial mailing list