I have a generic git repository called Workspace and each project I have that isn't big enough to deserve its own repository is stored as a folder within it. One of my mini-projects is now big enough that I feel it should have its own repository. I could easily make this happen by just copying the latest revisions into their own repository and committing them, but this doesn't transfer any of the previous revisions or history to the new repository. Is there a way to take a subfolder of a repo and make it its own repo without losing history?

I'm also fine with answers that only work for GitHub in case that has special features.


1 Answer 1


This is a common workflow; the Git team even added a command for it: git subtree will convert the directory into a submodule.

See this StackOverflow answer for more details: Detach subdirectory into separate Git repository: The Easy Way™.

  • Tell Brennan that he is not my senpai anymore. Commented May 9, 2015 at 2:42
  • 1
    I shall break his heart without mercy. Commented May 9, 2015 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.