Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Splitting folder to separate git repositories
# 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 git@bitbucket.org: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 git@bitbucket.org:xxxx/app-server.git
git push -f origin master
# 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 git@bitbucket.org: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 git@bitbucket.org: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
You can’t perform that action at this time.