Search code examples
gitgit-submodules

How to add a Git repo to another repo without knowing its URL?


I have a folder containing a few Git repos that I cloned and made changes to, and I'm trying to add those repos to a private repo that I own, but this is what I get:

warning: adding embedded git repository: [my repository]
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint: 
hint:   git submodule add <url> [my repository]

If I add the submodule at the URL where I originally cloned the repos from, I'd lose the changes I made (right?). So what URL do I enter so that my local copies of the cloned repos can be added to my new repo? Also, what would happen if I delete the .git files from those folders and just add them to my repo as regular folders? Would that achieve what I'm trying to do here?


Solution

  • I have a folder containing a few Git repos that I cloned and made changes to...

    If you made personal changes(changes different from the remote repository) to the submodules, there is no point of keeping them.

    If you no longer want to get the changes from those remote repositories, the best option is to just delete the .git folder from those local repositories. Since your parent directory is also a git repository, it will keep the changes in those local repositories.

    Another option is that you fork those remote repositories and add the URL of the forked repo as a submodule. Then you can push your own changes into your forks.