Let’s say you have a repository structure like below (eg. because previously it was SVN repository where everything was on one place).
- .\Web
- .\example.com
- .\example.net
- …
Now you would like to move example.com to separate git repository.
First of all, you need to install git-filter-repo.
# Clone old repository to new directory
git clone OLD_REPOSITORY example.com
cd example.com/
# Remove everything else except example.com directory
git filter-repo --path example.com/
# Make example.com new root directory
git filter-repo --subdirectory-filter example.com
# Push to a new repository
git remote add origin NEW_REPOSITORY
git push -u origin master