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

Example

Move directory (data/iossdb) from Git repository (git@github.com:lessos/lessgo.git) to a new Git repository (git@code.hooto.com:lynkdb/hissdb.git).

clone the original repository

git clone git@github.com:lessos/lessgo.git ~/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@github.com:lynkdb/ssdbgo.git
git push -u origin master
comments loading