Move subfolder into new GitHub repo

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):

  1. 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.

  2. Push to your already created new empty repo:
    git push git@github.com:chefbabe.git -f master
  3. Optional: Clean up (e.g. clone the original repo again) and to set your configs in /.git/config again
Advertisements
This entry was posted in news. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s