繁体   English   中英

将现有的git repos转换为父项目的子模块

[英]Turn existing git repos into submodules of parent project

我有几个无版本的项目,而这些项目又包含大量的插件,其中一些是git克隆。 我现在想把父项目变成一个git repo,最好不必遍历所有的插件,识别哪些是git repos,并手动将它们转换为父项目的子模块(当然,这是期望的结果) 。

是否有捷径可寻?

您可以使用简短的shell脚本执行此操作:

#!/bin/sh

for d in plugins/*
do
    if [ -e "$d/.git" ]
    then
        # Unstage the gitlink, so we can then add it back as a submodule:
        git rm --cached "$d"
        # Guess that the URL for origin is a reasonable one to use:
        URL="$(cd "$d" && git config remote.origin.url)"
        # Add the git repository back as a submodule:
        git submodule add "$URL" "$d"
    fi
done

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM