From: Christian Couder <chriscool@tuxfamily.org>
To: bill lam <cbill.lam@gmail.com>
Cc: Johannes Sixt <j.sixt@viscovery.net>, git <git@vger.kernel.org>,
Christian Couder <christian.couder@gmail.com>
Subject: Re: combine git repo historically
Date: Sun, 11 Oct 2009 04:36:52 +0200 [thread overview]
Message-ID: <200910110436.52653.chriscool@tuxfamily.org> (raw)
In-Reply-To: <20091010140358.GA3924@debian.b2j>
On Saturday 10 October 2009, bill lam wrote:
> On Fri, 09 Oct 2009, Johannes Sixt wrote:
> > bill lam schrieb:
> > > I have two git repos, no branches.
> > >
> > > repo 1.
> > > emptyrootcommit -- A ... M
> > >
> > > repo 2.
> > > emptyrootcommit -- N ... Z
> > >
> > > N was evolved from M but the time gap is large, how can I combine
> > > them into one repo
> > >
> > > emptyrootcommit -- A ... M -- N ... Z
> > >
> > > so that snapshots N .. Z will not be changed.
> >
> > $ echo $(git rev-parse N) $(git rev-parse M) >> .git/info/grafts
> > $ git filter-branch --tag-name-filter cat -- --all --not M
> >
> > i.e. you graft the older history right before the younger history, then
> > you use git filter-branch to rewrite the parentship of the younger
> > commits.
>
> Thanks, graft is new to me. I tested it works but it needs first issue
> git fetch /path/to/repo1
> within repo2 to fetch tip M from repo1 into repo2, is it correct?
>
> If I also want to fetch also all objects from repo1, what will the
> command to do it.
Maybe you should do something like:
$ git remote add repo1 /path/to/repo1
$ git fetch repo1
The fetch command should output something like:
remote: Counting objects: 423, done.
remote: Compressing objects: 100% (149/149), done.
remote: Total 363 (delta 276), reused 298 (delta 213)
Receiving objects: 100% (363/363), 136.65 KiB, done.
Resolving deltas: 100% (276/276), completed with 29 local objects.
From /path/to/repo1
* [new branch] branch1 -> repo1/branch1
* [new branch] branch2 -> repo1/branch2
So the branches in repo1 will be available in repo2 as remote/repo1/branch1,
remote/repo1/branch2, ...
> Christian Couder also mentioned the git-replace command, how to stitch
> with it?
First you need to create a commit that will replace commit N, let's call it
N' and after that you can use "git replace N N'". So the complex part is to
create N'.
You want N' to have the same content as N but to have M as parent. So you
could do something like the following:
(We suppose that commits A to M are in branch1 and that you are in the root
directory of your repo2 working directory.)
$ git checkout -b repo1-branch1 remote/repo1/branch1
$ git checkout N -- .
$ export GIT_AUTHOR_NAME=<author name of commit N>
$ export GIT_AUTHOR_EMAIL=<author email of commit N>
$ export GIT_AUTHOR_DATE=<date of commit N>
$ git commit -a
And then use the commit message from commit N, and maybe also say in the
commit message that it is replacement commit made to link repo1 with repo2
or something like that.
At this step you have created N' and you should make sure that it is exactly
what you want. It should point to the same tree as N, it should have M as
parent, ...
If everything is ok then you can use:
$ git replace N HEAD
And you should be done.
Regards,
Christian.
next prev parent reply other threads:[~2009-10-11 2:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-09 1:22 combine git repo historically bill lam
2009-10-09 6:02 ` Johannes Sixt
2009-10-09 7:40 ` Christian Couder
2009-10-10 14:03 ` bill lam
2009-10-11 2:36 ` Christian Couder [this message]
2009-10-11 4:06 ` bill lam
2009-10-11 10:11 ` Christian Couder
2009-10-11 8:48 ` Jakub Narebski
2009-10-11 13:07 ` Johannes Sixt
2009-10-11 13:43 ` Christian Couder
2009-10-11 14:29 ` Jakub Narebski
2009-10-11 9:34 ` Andreas Schwab
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=200910110436.52653.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--cc=cbill.lam@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
/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).