Skip to content

Instantly share code, notes, and snippets.

@gboddin

gboddin/init.sh

Last active Aug 29, 2015
Embed
What would you like to do?
git subtree subdirectory without index clashes
git remote add -f upstream_lib1 /repo.source.git
git fetch upstream_lib1
git remote add -f upstream_lib2 /repo.source.git
git fetch upstream_lib2
git remote add -f upstream_sites /repo.source.git
git fetch upstream_sites
git checkout -b upstream_lib1 upstream_lib1/master # now on upstream branch
git subtree split --prefix=lib1 --annotate="[lib1]" --rejoin -b subtrees/lib1
git checkout -b upstream_lib2 upstream_lib2/master # now on upstream branch
git subtree split --prefix=lib2 --annotate="[lib2]" --rejoin -b subtrees/lib2
git checkout -b upstream_sites upstream_sites/master # now on upstream branch
git subtree split --prefix=sites --annotate="[sites]" --rejoin -b subtrees/sites
git checkout master # go back to master
git subtree add --prefix=lib/lib1 subtrees/lib1 -m"merging lib1"
git subtree add --prefix=lib/lib2 subtrees/lib2 -m"merging lib2"
git subtree add --prefix=webroot/sites subtrees/sites -m"merging sites"
#!/bin/bash
set -x
git checkout upstream_lib1 # now on upstream
git reset --hard HEAD
git fetch upstream_lib1
git pull upstream_lib1 master
git subtree split --prefix=lib1 --annotate="[lib1]" --rejoin -b subtrees/lib1
git checkout master # go back to master
git subtree merge --prefix=lib/lib1 subtrees/lib1 -m"merged lib1"
git checkout upstream_lib2 # now on upstream
git reset --hard HEAD
git fetch upstream_lib2
git pull upstream_lib2 master
git subtree split --prefix=lib2 --annotate="[lib2]" --rejoin -b subtrees/lib2
git checkout master # go back to master
git subtree merge --prefix=lib/lib2 subtrees/lib2 -m"merged lib2"
git checkout upstream_sites # now on upstream
git reset --hard HEAD
git fetch upstream_sites
git pull upstream_sites master
git subtree split --prefix=sites --annotate="[sites]" --rejoin -b subtrees/sites
git checkout master # go back to master
git subtree merge --prefix=webroot/sites subtrees/sites -m"merged sites"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment