Create git project from subdirectory

We have a Git repository which contains a number of subdirectories. Now we have found that one of the subdirectories is unrelated to the other and should be detached to a separate repository.

  1. Prepare the old repo
    1
    2
    cd big-repo
    git subtree split -P name-of-folder -b name-of-new-branch
  2. Create the new repo
    1
    2
    3
    mkdir new-repo && cd new-repo
    git init
    git pull /path/to/big-repo name-of-new-branch
  3. Link the new repo to Github or wherever
    1
    2
    git remote add origin git@github.com:my-user/new-repo.git
    git push origin -u master
  4. Cleanup, if desired
    1
    2
    cd big-repo
    git rm -rf name-of-folder

Source: http://stackoverflow.com/questions/359424/detach-subdirectory-into-separ...

Tags