- Create a new folder where would place the new repo
- git clone the original repo under this folder
- Download
git-filter-repo
from here: (Do not chagne its extension)- https://raw.githubusercontent.com/newren/git-filter-repo/main/git-filter-repo
- Place
git-filter-repo
to the cloned repo root folder
- cd the cloned repo root folder, and run following:
python git-filter-repo --path <directory_to_separate_to_new_repo> --force
- Copy follwing files to root path of the new folder created in step 1:
- Remaining files under
<directory_to_separate_to_new_repo>
.git
directory in original repo root folder- Run
git status
in the new folder root, to check the git status - Run
git rev-list --count main
to check the commits count of separated directory
- Remaining files under
git add .
, and commit the change as a re-organizing of file structure- Create new repo in Github, and get its url, then run:
git remote add origin https://github.com/<owner>/<new_repo>.git git remote -v git push -u origin main
-
将子文件夹拆分成新仓库 - GitHub 文档
-
newren/git-filter-repo: Quickly rewrite git repository history (filter-branch replacement)