Skip to content

Instantly share code, notes, and snippets.

@nucknorris
Created February 27, 2014 12:35
Show Gist options
  • Save nucknorris/9249255 to your computer and use it in GitHub Desktop.
Save nucknorris/9249255 to your computer and use it in GitHub Desktop.
# Go into the project root
cd ~/my-project
# Create a branch which only contains commits for the children of 'foo'
git subtree split --prefix=foo --branch=foo-only
# Remove 'foo' from the project
git rm -rf ./foo
# Create a git repo for 'foo' (assuming we already created it on github)
mkdir foo
pushd foo
git init
git remote add origin git@github.com:my-user/new-project.git
git pull ../ foo-only
git push origin -u master
popd
# Add 'foo' as a git submodule to `my-project`
git submodule add git@github.com:my-user/new-project.git foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment