Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ericzumba/e4f46162b0ccfcc1ed8fe56c74bd1c3a to your computer and use it in GitHub Desktop.
Save ericzumba/e4f46162b0ccfcc1ed8fe56c74bd1c3a to your computer and use it in GitHub Desktop.
Git: Moving an internal folder to its own repo
cp -r old-repo new-repo
cd new-repo
git remote rm origin
git clean -fd
git filter-branch --subdirectory-filter internal-folder -- branch-to-hold-on-to
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git checkout branch-to-hold-on-to
git tag | xargs -I {} git tag -d {}
git branch | grep -v "*" | xargs -I {} git branch -D {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment