Submodules and merging
Quoted 1 line
From an earlier discussion here on the mailing list I had the
impression that there was some support for merging submodules from the supermodule. This does not seem to be the case, but I think it would be very good if this WAS possible?
Here is the shortest example that still mimics "real" work that shows the problem. Assume change1 and change2 are done by two different people in two different repositories and push this into separate branches in a central repo somewhere. A maintainer at the central repo wants to merge in one or both changes:
# Create directory and some repos with a simple README rm -rf submodule-test
mkdir submodule-test
cd submodule-test
( mkdir super-module; cd super-module; git init ) ( mkdir sub-module; cd sub-module; git init )
cd super-module
echo 'this is the super module' > README
git add README
git commit -m 'added a readme'
cd ../sub-module
echo 'this is the sub module' > README
git add README
git commit -m 'added a readme'
cd ..
# Make a testdir, clone the master repo, and add
# the sub-module mkdir testdir cd testdir git clone `pwd`/../super-module cd super-module git submodule add `pwd`/../../sub-module git commit -m 'added the submodule'
# make change1 on a branch in both super and sub module git checkout -b change1 cd sub-module/ git checkout -b sub-change1 echo 'This is change1' > change1 git add change1 git commit -m 'added change1 file' cd .. git add sub-module git commit -m 'did change1 in change1 branch'
# Make change2 on a branch in both super and sub module git checkout -b change2 master
git submodule update
cd sub-module/
git checkout -b sub-change2
echo 'this is change2' > change2
git add change2
git commit -m 'added change2 file'
cd ..
git add sub-module
git commit -m 'did the change2 change'
# Try to merge change1 and change2
git checkout -b mergetest master
git submodule update
git merge change1
git merge change2
This fails with the somewhat obscure error message:
fatal: cannot merge modes?
Merge with strategy recursive failed.
- Finn Arne