R's Workshop

Split A Subfolder into A New Git Repository

將大型 git project 的資料夾拆成小 git project 管理, 並保留對應的 commit log

Install git-filter-repo

sudo apt install git-filter-repo

Usage

– Clone large-size git project fitst

git clone REMOTE_GIT_REPOS_URL

– Filter out a subfolder from the repository and set the subfolder as new root folder

git filter-repo --subdirectory-filter SUB_FOLDER_NAME

– Create a new git repos and fetch filtered repos to the new git repos

Reference

Git