GIT Splitting a subfolder out into a new repository

From Luniwiki
Jump to: navigation, search

Create a new repository

See GIT_repository_on_Ubuntu#Create_repository to create the new repository.

Clone the actual repository

git clone https://<USER><REPOSITORY> <LOCAL_FOLDER>


git clone BIGRepo

Filter only the folder

git filter-branch --prune-empty --subdirectory-filter <REMOTE_FOLDER> <BRANCH>


cd BIGRepo/
git filter-branch --prune-empty --subdirectory-filter LittleFolder master

Change origin to new repository

git remote set-url origin https://<USER><NEW_REPOSITORY>


git remote -v
origin (fetch)
origin (push)
git remote set-url origin
git remote -v
origin (fetch)
origin (push)

Push the split folder to the new repository

git push -u origin <BRANCH>


git push -u origin master               
Password for '':
Counting objects: 3385, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2703/2703), done.
Writing objects: 100% (3385/3385), 7.43 MiB | 51.05 MiB/s, done.
Total 3385 (delta 691), reused 3130 (delta 617)
remote: Resolving deltas: 100% (691/691), done.
 * [new branch]        master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.


Daniel Simao (talk) 13:55, 8 February 2019 (EST)