Content Entry

Move a Subdirectory of Git to a new Git repository and keep its commit history

Published: 2017-08-16 Categories: Tips Tags: Git Subdirectory


Move directory (data/iossdb) from Git repository ( to a new Git repository (

clone the original repository

git clone ~/temp-lessgo
cd ~/temp-lessgo
git filter-branch --subdirectory-filter data/iossdb -- --all

create new repository

mkdir ~/new-hissdb
cd ~/new-hissdb

git init
git pull ~/temp-lessgo master
git remote add origin
git push -u origin master
comments loading