git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Merge two repos with history included? (was Re: How do I..?)
@ 2008-12-22 22:04 Dylan Martin
  2008-12-23  0:44 ` Miklos Vajna
  0 siblings, 1 reply; 3+ messages in thread
From: Dylan Martin @ 2008-12-22 22:04 UTC (permalink / raw)
  To: git

I tried converting an existing SVN repo to git and then adding it to
my main git repo using the subtree merge technique described at
http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html.
 I now have the various files in my repo, but they have no history.
I checked, and my initial SVN to git conversion does contain history.

I'm trying to add an exising repo as a subdir of my main repo with
history included.  Can anyone tell me how to do that?

I'm sorry if I'm phrasing my question badly, or if I'm asking
something that should be obvious...

Thanks!
-Dylan

On Wed, Dec 17, 2008 at 3:49 PM, Miklos Vajna <vmiklos@frugalware.org> wrote:
> On Wed, Dec 17, 2008 at 03:16:59PM -0800, Dylan Martin <dmartin@sccd.ctc.edu> wrote:
>> Sorry if this is a dumb question.  I've poked around the docs and
>> tried the google searches I could think of, but I don't even know what
>> kind of search terms one would use in trying to answer this.
>>
>> I'm a sysadmin and I've got a big monolithic git repo of all my
>> scripts, documents, etc...  It used to be a CVS repo but I converted
>> it to git a while ago.
>> Before I switched to git, I played around with SVN a bit, and started
>> a few tiny SVN repos for various scripts I was working on.  So, I know
>> have one git repo with %90 of my stuff and a handful of SVN repos.
>> I'd like to be able to add the SVN repos as subdirectories inside my
>> git repo.  I've found lots of pages describing how to convert an SVN
>> repo into a _new_ git repo, but I haven't found anything yet about
>> importing the contents of an SVN repo as a subdirectory of an
>> _existing_ git repo.
>
> I would convert each repo to git, then merge them using subtree merge.
> See Documentation/howto/using-merge-subtree.txt.
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Merge two repos with history included? (was Re: How do I..?)
  2008-12-22 22:04 Merge two repos with history included? (was Re: How do I..?) Dylan Martin
@ 2008-12-23  0:44 ` Miklos Vajna
  2008-12-23  7:58   ` Alexander Gavrilov
  0 siblings, 1 reply; 3+ messages in thread
From: Miklos Vajna @ 2008-12-23  0:44 UTC (permalink / raw)
  To: Dylan Martin; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1124 bytes --]

On Mon, Dec 22, 2008 at 02:04:06PM -0800, Dylan Martin <dmartin@sccd.ctc.edu> wrote:
> I tried converting an existing SVN repo to git and then adding it to
> my main git repo using the subtree merge technique described at
> http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html.
>  I now have the various files in my repo, but they have no history.

They have, but you are right about that - due to the nature of subtree
merge - git log <path> will show only the merge commits. (However git
blame works fine, for example.)

> I checked, and my initial SVN to git conversion does contain history.
> 
> I'm trying to add an exising repo as a subdir of my main repo with
> history included.  Can anyone tell me how to do that?

I would try the following: Let's say you have super.git and foo.git, and
you want to merge foo.git to the subdirectory 'foo' of super.git. Then
you can do in foo.git:

mkdir foo
mv * foo
git add foo
git commit -a

Then in super.git:

git pull path/to/foo.git master

And then git log --follow should work just fine on any merged files as
well.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Merge two repos with history included? (was Re: How do I..?)
  2008-12-23  0:44 ` Miklos Vajna
@ 2008-12-23  7:58   ` Alexander Gavrilov
  0 siblings, 0 replies; 3+ messages in thread
From: Alexander Gavrilov @ 2008-12-23  7:58 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: Dylan Martin, git

On Tuesday 23 December 2008 03:44:07 Miklos Vajna wrote:
> On Mon, Dec 22, 2008 at 02:04:06PM -0800, Dylan Martin <dmartin@sccd.ctc.edu> wrote:
> > I checked, and my initial SVN to git conversion does contain history.
> > 
> > I'm trying to add an exising repo as a subdir of my main repo with
> > history included.  Can anyone tell me how to do that?
> 
> I would try the following: Let's say you have super.git and foo.git, and
> you want to merge foo.git to the subdirectory 'foo' of super.git. Then
> you can do in foo.git:
> 
> mkdir foo
> mv * foo
> git add foo
> git commit -a
> 
> Then in super.git:
> 
> git pull path/to/foo.git master
> 
> And then git log --follow should work just fine on any merged files as
> well.
> 


If the conversion is one-shot, you can also try rewriting commits like this:

cd foo.git
git filter-branch --commit-filter 'TREE=$1; shift; git commit-tree $(echo -e "040000 tree $TREE\tfoo" | git mktree) "$@"' master

(Maybe there is a simpler way, though)

I used this once to merge together the history of a bunch of interrelated (and now dead) projects.

Alexander

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-23  8:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-22 22:04 Merge two repos with history included? (was Re: How do I..?) Dylan Martin
2008-12-23  0:44 ` Miklos Vajna
2008-12-23  7:58   ` Alexander Gavrilov

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).