From: "Алексей Шумкин" <zapped@mail.ru>
To: Jakub Narebski <jnareb@gmail.com>
Cc: git@vger.kernel.org
Subject: Re[2]: Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?
Date: Tue, 11 Jan 2011 17:49:07 +0300 [thread overview]
Message-ID: <961742587.20110111174907@mail.ru> (raw)
In-Reply-To: <m3lj2rbmq5.fsf@localhost.localdomain>
Hello, Jakub.
Thank you very much. Your method works great and it suits for me well
>> 1.5 years ago I had sources of a project in a SVN repository (actually it does not
>> matter what SCM was used before). And I had two branches: v2.4 and v2.5.
>> They differed enough at that moment and (as usual for SVN branches)
>> laid in two different folders.
>> Then I had known of Git and I decided to try to use this powerful DVCS.
>> But as I was a newbie I created two git-repositories: one per each
>> branch. So v2.4 has its own git-repo. v2.5 (and above) has another one.
>>
>> Now I'd like to merge them as v2.5 was a continuos branch from v2.4,
>> but without a rebasing (i.e. without a global changing of v2.5
>> repository, which already has another branches)
>> It must look like LAST commit of v2.4 should be a PARENT of FIRST commit of v2.5
>>
>> Now there's a question: Is it possible to do so (no rebasing!), and If
>> "yes" then how to?
JN> As Andreas Ericsson wrote, you can do this using grafts (and you can
JN> make history with grafts permanent using "git filter-branch").
JN> Better solution might be to use more modern replace mechanism, see
JN> e.g. "git replace" manpage. Below there is untested step-by-step
JN> instruction.
JN> First, you have put history of v2.4 and of v2.5 in a single repository
JN> (e.g. using "git remote add"). Then you need to find FIRST commit of
JN> v2.5 among
JN> $ git rev-list master --parents | grep -v ' '
JN> The above finds all parent-less commits in 'master' branch; replace it
JN> with branch holding v2.5 history. Then you need to find LAST commit
JN> of v2.4 and its SHA-1, e.g. via
JN> $ git rev-parse v2.4
JN> Save current state of FIRST commit of v2.5 to a file
JN> $ git cat-file -p FIRST > tmp
JN> Edit this file, adding 'parent' line between 'tree' and 'author'
JN> headers, so the header of this file looks like the following:
JN> tree 13d050266e05f7c66000240814199fcf3b559d43
JN> parent ada9983c4256f5a7bac1f7f0e29d52011741d6aa
JN> author Jakub Narebski <jnareb@gmail.com> 1294231771 +0100
JN> (trailing space added for better readibility).
JN> Then you need to add newly created object to repository:
JN> $ git hash-object -t commit -w tmp
JN> and then use it as replacement
JN> $ git replace <SHA-1 of FIRST> <SHA-1 returned by hash-object>
JN> Finally check that replacement works, e.g.:
JN> $ git show FIRST
JN> $ git log --graph --oneline -3 FIRST
JN> The anyone who would fetch refs/replace/ would get joined history, and
JN> who doesn't would see it not connected.
JN> P.S. This probably should made it into Documentation/howto
next prev parent reply other threads:[~2011-01-11 14:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-11 10:41 Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible? Алексей Шумкин
2011-01-11 11:49 ` "Martin Krüger"
2011-01-11 12:33 ` Re[2]: " Алексей Шумкин
2011-01-11 12:41 ` Andreas Ericsson
2011-01-11 14:58 ` Re[2]: " Алексей Шумкин
2011-01-11 12:47 ` "Martin Krüger"
2011-01-11 13:21 ` Jakub Narebski
2011-01-11 14:49 ` Алексей Шумкин [this message]
2011-01-11 15:16 ` Re[2]: " Алексей Шумкин
2011-01-12 0:08 ` [RFC/PATCH] Documentation: start to explain what git replace is for Jonathan Nieder
2011-01-12 22:47 ` Maaartin
2011-01-13 7:52 ` Alexey Shumkin
2011-01-14 8:49 ` [RFC/PATCH 2/1] fixup! " Jonathan Nieder
2011-01-14 17:44 ` Maaartin-1
2011-01-14 19:30 ` Jonathan Nieder
2011-01-14 21:09 ` how multiple roots happen (Re: [RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for) Jonathan Nieder
2011-01-14 22:48 ` [RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for Jakub Narebski
2011-01-15 0:04 ` Maaartin-1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=961742587.20110111174907@mail.ru \
--to=zapped@mail.ru \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).