Make a new repo from a subdirectory of an original repo
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
# Please don't just RUN this. Do it step-by-step. | |
user=bocoup | |
orig_repo=training | |
new_repo=training-jquery | |
subdir=jquery-conference | |
# Pull down the original repo. | |
git clone git@github.com:$user/$orig_repo.git $new_repo | |
# Repo, I'm in you. | |
cd $new_repo | |
# Rewrite history, removing everything but files in the "subdir" directory. | |
# This moves all those files into the root as well. Not sure that this | |
# handles all refs, not sure that I care. | |
git filter-branch --subdirectory-filter $subdir -- --all | |
# Verify there aren't any missing renamed files, et (per man page). | |
git log --name-only --follow --all -- filename | |
# In the GitHub admin, create a new repo for "user" with name "new_repo". | |
# Remove the "orig_repo" origin remote. | |
git remote rm origin | |
# Add the new "new_repo" origin remote. | |
git remote add origin git@github.com:$user/$new_repo.git | |
# Push to GitHub. | |
git push -u origin master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment