0

So I have been working on a project which deals with multiple git repos, and until now it's just existed on my local filesystem:

/workspace
    /repo1 <- git repo
    /repo2 <- git repo

I would like to convert the workspace directory to a git repo, with the contained directories as submodules, like so:

/workspace <- git repo
    /repo1 <- submodule
    /repo2 <- submodule

So I understand that with git submodules, I can add a module like so:

git submodule add <repo1 url>
git submodule add <repo2 url>

But my assumption is that this will clone these repos to my system, possibly over-writing the local versions.

Is there a way to tell git: "this directory is already a git repo: turn it into a submodule"?

sak
  • 2,612
  • 24
  • 55
  • https://stackoverflow.com/search?q=%5Bgit-submodules%5D+add+existing – phd Jul 23 '22 at 09:50
  • See https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-add-bltbranchgt-f--force--nameltnamegt--referenceltrepositorygt--depthltdepthgt--ltrepositorygtltpathgt and https://stackoverflow.com/a/28706225/7976758 : "*If does exist and is already a valid Git repository, then this is added to the changeset without cloning.*" – phd Jul 23 '22 at 09:51

0 Answers0