Created
December 9, 2016 04:27
-
-
Save jatcwang/7257a762f2fbcdeae69e0cb0ba3e9df7 to your computer and use it in GitHub Desktop.
Git subtree split a directory into new repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imagine this project structure | |
proj_a/ | |
lib_b/ ... contents you want to split | |
First create a new git repository somewhere in the file system | |
mkdir /lib_b | |
cd /lib_b | |
git init | |
# Allow pushing to currently checked out branch | |
git config receive.denyCurrentBranch ignore | |
# back to proj_a | |
cd /proj_a | |
# Setup remote | |
git remote add lib_b /lib_b | |
# Split the history for lib_b subdirectory and push into lib_b remote's master branch | |
git subtree push --prefix=lib_b lib_b master | |
# ... handle further changes in /lib_b, with full history for that module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment