Git add all repositories under a certain path as submodules recursively

How can I add all sub-repositories inside a just-initialized git repository as submodules?

I have two repositories I've been tracking separately, now I want to take those into a larger project, but still keep their respective origins.

I currently just did git init .

Also, if possible:

  • Without removing any directories temporarily
  • Without using a bash script

  • You can try something like:

    find . -maxdepth 1 -type d -exec git submodule add ./{} ;
    

    That should fail for regular folders, and succeed for folders which are nested git repo within your main repo you just initialized.

    Once added, you will need to commit in your main repo, in order to record all the gitlinks you just created (with submodule add ).

    Note that you would still have to update the url of those submodules you just added (because their current url would be their own folder)

    链接地址: http://www.djcxy.com/p/92322.html

    上一篇: 在git中修改嵌套子模块的URL

    下一篇: Git以递归方式添加子模块的特定路径下的所有存储库