Re: Merging submodules (was Re: Feature suggestion: git-hist)
From: H.Merijn Brand <hidden>
Date: 2016-06-15 22:45:05
On Wed, 30 Jul 2008 11:15:55 -0400, Brian Gernhardt [off-list ref] wrote:
On Jul 30, 2008, at 9:58 AM, H.Merijn Brand wrote:quoted
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/*
All went well
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 indexSo far so good.
git merge --no-commit -s ours module_a/master module_b/master module_c/master
$ git merge --no-commit -s ours fnc/master i00f000/master i99f000/master include/master l00m000/master l01f000/master l02f000/master l03f000/master l06f000/master l90z000/master leerpl/master mutbev/master prtabel/master rpt/master tabellen/master zoomen/master Automatic merge went well; stopped before committing as requested
git commit --amend
$ git commit --amend fatal: You are in the middle of a merge -- cannot amend. $ git status # On branch master nothing to commit (working directory clean) When I start git-gui, it still shows a long commit message: Merge commit 'fnc/master'; commit 'i00f000/master'; commit 'i99f000/master'; commit 'include/master'; commit 'l00m000/master'; commit 'l01f000/master'; commit 'l02f000/master'; commit 'l03f000/master'; commit 'l06f000/master'; commit 'l90z000/master'; commit 'leerpl/master'; commit 'mutbev/master'; commit 'prtabel/master'; commit 'rpt/master'; commit 'tabellen/master'; commit 'zoomen/master' All other areas are clear
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.
-- H.Merijn Brand Amsterdam Perl Mongers http://amsterdam.pm.org/ using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, SuSE 10.1, 10.2, and 10.3, AIX 5.2, and Cygwin. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/