I recently had a GIT repository with a sub-directory that should have been it own repository. I also wanted to keep all of the history in the sub-directory. These are the steps that I followed to move that sub-directory into a new separate GIT repository.
project/ .git/ p1/ p2/ p3/
project/ .git p1 p3 p2/ .git
$ git clone --no-hardlinks project p2 Cloning into nuget-packages... done. $ cd p2 $ git gc Counting objects: 640, done. Delta compression using up to 2 threads. Compressing objects: 100% (225/225), done. Writing objects: 100% (640/640), done. Total 640 (delta 401), reused 605 (delta 390) $ git status # On branch master nothing to commit (working directory clean) $ git filter-branch --subdirectory-filter p2 HEAD -- --all Rewrite 352c51285e647fc31d37aa42479162160def0594 (31/31) Ref 'refs/heads/master' was rewritten $ git reset --hard HEAD is now at df4f12e removed nant from source control, it is now stored locally on the drive outside of the repository... $ rm -rf .git/refs/original/ $ git reflog expire --expire=now --all $ git gc --aggressive --prune=now Counting objects: 671, done. Delta compression using up to 2 threads. Compressing objects: 100% (646/646), done. Writing objects: 100% (671/671), done. Total 671 (delta 426), reused 214 (delta 0)