Skip to content

Instantly share code, notes, and snippets.

@mwhite
Last active December 16, 2015 18:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mwhite/5478061 to your computer and use it in GitHub Desktop.
Save mwhite/5478061 to your computer and use it in GitHub Desktop.
#!/bin/bash
# subtree merge with branches
rm -rf commcare-hq core-hq
git clone git://github.com/dimagi/commcare-hq.git
git clone git://github.com/dimagi/core-hq.git
cd core-hq
git checkout master
git rm .gitignore README.rst
git commit -m "remove .gitignore in preparation for merge"
branches=$(git branch --remote --no-merged | cut -d/ -f 2)
for branch in $branches; do
git checkout -b $branch origin/$branch
git rm .gitignore README.rst
git rm __init__.py
git commit -m "remove .gitignore in preparation for merge"
done
branches="master $branches"
cd ../commcare-hq
git rm submodules/core-hq-src
git commit -m "remove core-hq-src submodule"
git remote add -f core-hq ../core-hq/.git
for branch in $branches;
do
echo subtree merging $branch
git checkout master
git checkout -b core-hq-$branch
git merge -s ours --no-commit core-hq/$branch
git read-tree --prefix= -u core-hq/$branch
git commit -m "subtree merged in core-hq ($branch branch)"
done
git checkout master
git merge core-hq-master
for branch in $branches;
do
git checkout -f core-hq-$branch
git merge --no-edit master
done
# git push --all origin
exit 0
# anyone with a fork of core-hq can do the following to merge their changes into their fork of commcare-hq
cd core-hq-src
git rm .gitignore README.rst
git commit -m "remove conflicting files"
cd ../../
git remote add -f core-hq submodules/core-hq-src/.git
git merge -s ours --no-commit core-hq/mybranch
git read-tree --prefix= -u core-hq/mybranch
git commit -m "subtree merged in core-hq (mybranch branch)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment