# 1. Clone the remote
git clone monster-repository project-repository
# 2. change dir
cd project-repository
# 3. Remove the remote
git remote rm origin
# 4. Filter branch
git filter-branch --tag-name-filter cat --prune-empty --subdirectory-filter project-directory HEAD
# 5. Clean up
git reset --hard
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all
git gc --aggressive --prune=now
# 7. Add a new remote and push
git remote add origin [url]
git push origin master
Source http://jamesreubenknowles.com/how-to-extract-a-subdirectory-as-a-new-git-repository-1566
# Move root into probruntime
git filter-branch -f --prune-empty --tree-filter '
mkdir -p .sub;
mv * .sub;
mv .sub probruntime
' -- --all
# Rewrite path of probruntime to ide/probruntime
git filter-branch -f --tree-filter 'mkdir -p ide; mv probruntime/ ide/' HEAD
git tag -l | xargs git tag -d