Detach subdirectory into separate Git repository

Posted by matli on Stack Overflow See other posts from Stack Overflow or by matli
Published on 2008-12-11T13:57:03Z Indexed on 2010/03/22 21:01 UTC
Read the original article Hit count: 247

Filed under:
|

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

How can I do this while keeping the history of the files within the subdirectory?

I guess I could make a clone and remove the unwanted parts of each clone, but I suppose this would give me the complete tree when checking out an older revision etc. This might be acceptable, but I would prefer to be able to pretend that the two repositories doesn't have a shared history.

Just to make it clear, I have the following structure:

XYZ/
    .git/
    XY1/
    ABC/
    XY2/

But I would like this instead:

XYZ/
    .git/
    XY1/
    XY2/
ABC/
    .git/

© Stack Overflow or respective owner

Related posts about git

Related posts about git-filter-branch