I'm making a git extension. It's in its own git repo. To run tests, I have created several test repos which are used by my project. Currently they are submodules of the main repo.

I am dissatisfied with this. Firstly they themselves need to be cloned (in case the original cloner didn't use --recursive) as part of the test setup, but, more importantly, the project is not self-contained. One can't just migrate the project to another server without taking care of the helper submodules. Even if you have cloned the original repo, you need to make sure you have access to the helpers.

So, since I need a test setup anyway, I was considering instead of using submodules to build the test repos to their desired state from scratch with helper scripts.

Then I figured that it will probably be more efficient to create the bare test repos myself once, add them as a tarball in the original, and unpack it as part or the test setup.

Then I wondered... is there an even easier way to do this? Can I safely add entire git repos inside of another instead of using submodules? Then there won't even be a need for a test setup.

  • see Where does my git question go? – gnat Dec 8 '20 at 18:00
  • 1
    I still think this is more of a SE (a workflow) question than a "question about git the tool". It's about the concept of adding entire git repos inside of another. What is the best way to do it? But thanks for downvoting without reading :) – Borislav Stanimirov Dec 8 '20 at 18:32

Depending on the contents of the git repos, I would prefer to create them programatically. e.g dont check in a tarball or the git repo itself, but instead check in a script that creates the repo from scratch.

The advantages being: the script is small and easy to deal with. Also it could sidestep som issues with old repos. In general git is fairly stable, but there could be some corner cases when working on a 10+ years old repo.


You may also use Git X-Modules. It's a tool to sync a directory inside your repository with some external repository, so you keep your modular structure intact, and yet have all the code you need inside your repository.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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