Take the 2-minute tour ×

When using git subtree an entire new tree, including a new first commit, is created in the same repository in which it was created. This means that at that point the repository contains two completely independent trees inside it, with no common parent at all.

What would be a good way to move this new tree to its own repository?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

One approach is to create an empty git repository, add it as a remote of the original repository and then push only the new subtree to it. That will move only the commits from the new subtree into the new repo.

# create new repository
> mkdir newRepo
> cd newRepo
> git init

# add remote in the original repo
> cd /path/to/originalRepo
> git remote add newRepo /path/to/newRepo

# push only new subtree
> git push newRepo <hash-of-subtree>:subtreeBranch
share|improve this answer
This works, but I am looking for a better approach. If perhaps a git repository can create clones of specific references in itself. –  LopSae Jan 15 '13 at 4:11

Your Answer


