【问题标题】:How can I add a git submodule with the same name as an old, deleted git directory?如何添加与旧的已删除 git 目录同名的 git 子模块?
【发布时间】:2014-03-23 11:26:29
【问题描述】:

我正在尝试将一个目录变成一个子模块,并有效地将这个东西变成一个 git 超级项目/项目,里面有专门的子模块。我有一个“构建”目录(对于我正在制作的东西是必需的,因为一些依赖项是封闭源代码,因此不在 git repo 中,这意味着有些人无法构建自己的版本),但我想把它变成一个单独的仓库,放在和以前一样的位置。也就是说,我希望它不是 /built 作为 repo 跟踪的目录,而是 /built 作为不同 repo 跟踪的子模块。

但是,当我尝试删除 /built、提交并执行 git submodule add BUILT_REPO_URL built 时,我得到:

A git directory for 'built' is found locally with remote(s):
  origin        BUILT_REPO_URL
If you want to reuse this local git directory instead of cloning again from
  BUILT_REPO_URL
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.

(我已将 BUILT_REPO_URL 替换为适当的 git 存储库托管 URL。)

我不想重命名该目录,因为这看起来很奇怪,而且我有构建脚本以及我必须更改的东西。此外,我还想对其他目录执行此操作,并且它们具有基于我正在使用的框架的相当设置的目录结构。我试过从缓存中删除文件(那里没有)和其他类似的步骤。该问题也无法通过 Google 搜索,因为我发现的所有结果都是将子模块更改为具有相同目录名称的不同子模块。

【问题讨论】:

    标签: git local directory git-submodules


    【解决方案1】:

    确保您首先删除并提交了“built”文件夹。

    git rm -rf built
    # or, if built isn't in the working tree
    git rm --cached -rf built
    git add -A
    git commit -m "remove built"
    

    那你可以试试你的git submodule add。

    【讨论】:

    • 原来我去了全空间学员,忘记了几个月前我已经尝试将其添加为子目录,这意味着它仍然潜伏在.git/modules/。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-30
    • 1970-01-01
    • 1970-01-01
    • 2014-05-31
    • 1970-01-01
    • 2017-06-16
    • 2018-08-10
    相关资源
    最近更新 更多