Created
April 20, 2018 14:10
-
-
Save holms/c42927d8a24b909992aea39d2261b342 to your computer and use it in GitHub Desktop.
Splitting folder to separate git repositories
This file contains hidden or 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
# So we have this situation: repo `app` which has `serverapp` folder inside which we want to convert to separate repo | |
rm -rf app | |
rm -rf app-server | |
git clone [email protected]:xxxx/app.git | |
cp -R app app-server | |
cd app-server | |
git filter-branch --prune-empty --subdirectory-filter serverapp master | |
echo node_modules/ >> .gitignore # For node.js only | |
git add .gitignore # For node.js only | |
git commit -m 'Remove node_modules from git history' # For node.js only | |
git gc | |
git remote set-url origin [email protected]:xxxx/app-server.git | |
git push -f origin master | |
This file contains hidden or 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
# So we have this situation:; repo `app` which has `serverapp` folder inside, which we want to remove from history, and current repo (what's left in it) should be pushed to new origin | |
rm -rf app | |
rm -rf app-server | |
git clone [email protected]:xxxx/app.git | |
cp -R app app-frontend | |
cd aml-connect-frontend | |
git filter-branch --tree-filter 'rm -rf serverapp' --prune-empty HEAD | |
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d | |
echo serverapp/ >> .gitignore # or else it will complain about unstaged changes | |
git add .gitignore | |
git commit -m 'Remove serverapp from git history' | |
git gc | |
git remote set-url origin [email protected]:xxxx/app-frontend.git | |
git push origin master --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment