From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id C83DD1F463 for ; Tue, 17 Dec 2019 10:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727415AbfLQKCc convert rfc822-to-8bit (ORCPT ); Tue, 17 Dec 2019 05:02:32 -0500 Received: from mail.computer-surgery.co.uk ([82.69.253.61]:58190 "EHLO nicole.computer-surgery.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbfLQKCc (ORCPT ); Tue, 17 Dec 2019 05:02:32 -0500 Received: from [192.168.131.253] (helo=bath.backslashat.org) by nicole.computer-surgery.co.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ih9gS-0007ta-VI; Tue, 17 Dec 2019 10:02:29 +0000 Received: from roger by bath.backslashat.org with local (Exim 4.92) (envelope-from ) id 1ih9gN-00088U-16; Tue, 17 Dec 2019 10:02:23 +0000 Message-ID: Subject: Re: Merging two Git-Repositories From: Roger Gammans To: Steve Keller , git@vger.kernel.org Date: Tue, 17 Dec 2019 10:02:22 +0000 In-Reply-To: References: Organization: Gamma Science Ltd. (GB Nr. 07356014 ) Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.30.3-1 Mime-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Tue, 2019-12-17 at 10:28 +0100, Steve Keller wrote: > Is it possible to merge one Git-Repository into another? I have > developed two independent repositories A and B, and now I find that > B should be part of A in new sub-directory, e.g. A/B. I want to > move B into A while keeping the whole development history of B. > > How can I do that? It is possible bit isn't straightforward, at least not if you want to interleave the commits. If you don't want to interleave the commits, just rename everything (*) in B to B/*' and merge the repo with A's repo. Then you will have a the structure you want going forward, all the history together; but if you check out a historic commit you will have to decide to check out on the 'A' or 'B' branches. If you do want to interleave the comits the best found was ( https://metacpan.org/pod/distribution/Git-FastExport/script/git-stitch-repo to merge the repos. (from https://github.com/book/Git-FastExport/ ) I've got some updates ( https://github.com/rgammans/Git-FastExport/tree/hintfiles ) to it when I did some work on this a couple of years ago but the it looks like the upstream has improved a little since then. My changes allow you to try to give it hints in case in make mistakes, on choosing the correct parent for a commit. The whole system worked pretty well except where there were a lot a diverging/remerging branches. My process was to write a shell script to actually drive the process, and tweak the script to improve the results iteratively. Hope this helps a little. -- Roger Gammans