Created
February 17, 2014 17:15
-
-
Save nicolasochem/9054876 to your computer and use it in GitHub Desktop.
Branch-aware git submodules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x | |
cd /tmp/ | |
rm -rf submodules/ | |
mkdir submodules | |
cd submodules/ | |
# create component repositories | |
mkdir component_A | |
cd component_A | |
echo "initial commit" > a | |
git init | |
git checkout -b dev | |
git add a | |
git commit -a -m "dev commit" | |
git branch 3.11 | |
cd .. | |
mkdir component_B | |
cd component_B | |
git init | |
echo "initial comit" > b | |
git add b | |
git commit -a -m "dev commit" | |
git branch 3.11 | |
cd .. | |
# simulate some parallel work on development branch and release branch | |
cd component_A | |
echo "work on development" >> a | |
git commit -a -m "work on development" | |
git checkout 3.11 | |
echo "work on release" >> a | |
git commit -a -m "work on release" | |
cd .. | |
cd component_B | |
echo "work on development" >> b | |
git commit -a -m "work on development" | |
git checkout 3.11 | |
echo "work on release" >> b | |
git commit -a -m "work on release" | |
cd .. | |
# now make the superproject | |
mkdir superproject | |
cd superproject/ | |
git init | |
git submodule --branch dev add ../component_A/ component_A | |
git submodule --branch master add ../component_B/ component_B | |
git submodule update --remote | |
git submodule status | |
cat .gitmodules | |
git commit -a -m "Nightly build 345" | |
git tag "master-nightly-345" | |
# make the release branch of the superproject | |
git checkout -b 3.11 | |
# edit .gitmodules | |
sed -i "s/dev/3.11/" .gitmodules | |
sed -i "s/master/3.11/" .gitmodules | |
cat .gitmodules | |
git submodule update --remote | |
git submodule status | |
git commit -a -m "3.11 build 5" | |
git tag "3.11-nightly-5" | |
# test recusrive checkout | |
cd .. | |
git clone --recursive superproject superproject_clone -b master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment