Category Archives: Git

Migrate subfolder to separate git repository

Let’s say you have a repository structure like below (eg. because previously it was SVN repository where everything was on one place).

  • .\Web
    • .\
    • .\

Now you would like to move to separate git repository.

First of all, you need to install git-filter-repo.

# Clone old repository to new directory

# Remove everything else except directory
git filter-repo --path

# Make new root directory
git filter-repo --subdirectory-filter

# Push to a new repository
git remote add origin NEW_REPOSITORY
git push -u origin master