Created
June 20, 2017 15:22
-
-
Save nitrocode/a05c44aa7fc2bbbf39e1c4738ce747a9 to your computer and use it in GitHub Desktop.
Cut up a git repo into smaller repos
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
| # clone url of current repo | |
| curremote="git@github.com:xyz/123.git" | |
| newremote="ssh://git@git.xyz.com/123.git" | |
| # new cloned directory of current repo - doesn't matter the name | |
| newdirname="my-new-agent-repo" | |
| # original directory of files in current repo | |
| keepdir="my-current-agent" | |
| # clone and checkout branches | |
| #git clone --mirror $curremote $newdirname | |
| git clone $curremote $newdirname | |
| cd $newdirname | |
| # checkout branches | |
| git checkout origin/rc -b rc | |
| git checkout origin/dev -b dev | |
| # remove original remote to github | |
| git remote rm origin | |
| # remove all history except for the directory to keep - command takes a while | |
| git filter-branch -f --subdirectory-filter $keepdir -- --all | |
| # add new remote | |
| git remote add origin $newremote | |
| # push up branches | |
| git push --all | |
| git push --tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment