git submodule删除后重新添加问题

本文介绍了解决在Git中重新添加子模块时遇到的问题的方法,包括如何彻底删除旧的子模块及其配置,并重新添加新的子模块。
重新添加git 子模块出现的问题:
A git directory for 'formRenderLib' is found locally with remote(s):
  origin    git@gitlab.com:newcare/formRenderLib.git
If you want to reuse this local git directory instead of cloning again from
  git@gitlab.com:newcare/formRenderLib.git
use the '--force' option. If the local git directory is not the correct repo
or 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编辑器使用

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值