Skip to content

Instantly share code, notes, and snippets.

@xphere
Created April 13, 2015 15:34
Show Gist options
  • Save xphere/368d29c79df2c844b39f to your computer and use it in GitHub Desktop.
Save xphere/368d29c79df2c844b39f to your computer and use it in GitHub Desktop.
Instructions for splitting a directory in a repo and merge into another one
  1. Split directory in a branch in source repository

    git subtree split -P <name-of-folder> -b <name-of-new-branch>
    
  2. Add remote of source in destination repository and fetch

    git remote add -f <source> <source-repository>
    
  3. Merge splitted branch into destination without a new commit

    git merge -s ours --no-commit <name-of-source-branch>
    
  4. Import tree into new path

    git read-tree --prefix=<new-path> -u <name-of-source-branch>
    
  5. Commit merge

    git commit
    
@mmoreram
Copy link

Wee!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment