Sometimes it happens that you want to outsource a sub directory from your GitHub repository to a separate new repository.
e.g. you have a structure like
# github repo /electrobabe /chefbabe /app /papierwahl
and want to have a new structure like this
# old repo /electrobabe /papierwahl # new repo /chefbabe /app
This can be done super easy with only two commands (from help.github.com):
- in your original directory
cd electrobabe git filter-branch --prune-empty --subdirectory-filter chefbabe master
The directory electrobabe now only contains the files of chefbabe.
- Push to your already created new empty repo:
git push email@example.com:chefbabe.git -f master
- Optional: Clean up (e.g. clone the original repo again) and to set your configs in /.git/config again