git submodule删除后重新添加问题

来源:互联网 发布:java string 倒序 编辑:程序博客网 时间:2024/05/23 16:56

重新添加git 子模块出现的问题:

A git directory for 'formRenderLib' is found locally with remote(s):  origin    git@gitlab.com:newcare/formRenderLib.gitIf you want to reuse this local git directory instead of cloning again from  git@gitlab.com:newcare/formRenderLib.gituse the '--force' option. If the local git directory is not the correct repoor you are unsure what this means choose another name with the '--name' option.

说明没有删除干净之前的module


解决方法:

  1. 在主项目目录下打开命令行工具执行命令 git rm --cached path_to_submodule 删除指定模块的文件

  2. 打开主项目目录下 .gitmodules (可能会隐藏,需要显示设置)文件 删除如下类似内容:
    mac下使用命令 vim .gitmodules 可打开vim编辑

    [submodule "path_to_submodule"]        path = path_to_submodule        url = https://github.com/path_to_submodule
  3. 打开主项目目录下 .git/config 文件 删除如下内容:
    同样可使用vim编辑

    [submodule "path_to_submodule"]    url = https://github.com/path_to_submodule
  4. 使用命令行工具执行命令:rm -rf .git/modules/path_to_submodule 删除.git下的缓存模块

最后使用如下命令即可添加子模块 git submodule add https://github.com/path_to_submodule


参考

Git Submodule管理子模块

vim编辑器使用

原创粉丝点击