Merging submodules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This message got eaten by a syntax error somewhere.  This is a re-send, sorry for any duplicate messages.

On Jul 30, 2008, at 9:58 AM, H.Merijn Brand wrote:

> One (very) big disadvantage of  SCCS  is that commits are on a per-file
> basis, and only in a single directory. This drawback still haunts me in
> git, as my first attempts to convert were successful in a single folder
> and git cannot merge folders into a single project.
> 
> Say I now have
> 
> /work/src/project/.git
> /work/src/project/module_a/.git
> /work/src/project/module_b/.git
> /work/src/project/module_c/.git
> 
> Which are all converted repos from SCCS, I'd like to merge the three
> module_# repos into the top level repo.

Following the example of Linus, the following is completely untested.

First you fetch all of the heads/tags/etc into the superproject with commands like

git fetch module_a refs/heads/*:refs/remotes/module_a/*
git fetch module_b
refs/heads/*:refs/remotes/module_b/*
git fetch module_c
refs/heads/*:refs/remotes/module_c/*

Then you do something like:

rm -rf module_{a,b,c}/.git # Do this in a test repository, obviously...
git add module_a module_b module_c
git commit # Needed because '-s ours' uses current HEAD, not index
git merge --no-commit -s ours module_a/master module_b/master module_c/master
git commit --amend

>From this point on, the project repository has a merged history of the sub-projects, and if anyone doesn't catch up and still makes a commit on a subproject you can use "git merge -s subtree" to merge it in anyway.

You may need to "git rm --cached" some files after the "git add" step if your .gitignore files aren't perfect.

~~ Brian
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux