Split a subfolder out into a new repository

If you want to turn a folder within a Git repository into a brand new repository, and you don’t want to lose any of your Git history or changes, you can use git filter-branch command. For example,

git filter-branch --prune-empty --subdirectory-filter SUBFOLDER_NAME master

All the other files but the subfolder would be removed. Now you can add a new remote and then push it to your new location.