Skip to content

Instantly share code, notes, and snippets.

@brevans
Last active April 5, 2018 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brevans/c7397e1d7b7b6c5f3f06c463cc6cc30e to your computer and use it in GitHub Desktop.
Save brevans/c7397e1d7b7b6c5f3f06c463cc6cc30e to your computer and use it in GitHub Desktop.
# clone repo I want subtree from
git clone git@bitbucket.org:caseywdunn/agalma.git
cd agalma
# be paranoid and remove origin so I don't push back to origin
git remote rm origin
# filter subtree I want
git filter-branch --prune-empty --subdirectory-filter dev/conda master
# move subtree to match destination directory structure, maintaining history
git filter-branch -f --index-filter 'git ls-files -s | sed "s-\t\"*-&recipes/-" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
# clean up
git rm -r recipes/agalma
git commit -m "remove the agalma recipe"
cd ..
# clone destination repo
git clone git@github.com:caseywdunn/conda-recipes.git
cd conda-recipes
# add my subtree as a remote
git remote add agalma ../agalma
git fetch --all
# merge
git merge --allow-unrelated-histories agalma/master -m "merging agalma recipes into new recipe repo"
# clean and push
git remote rm agalma
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment