gpt4 book ai didi

git - 如何添加一个与旧的、已删除的 git 目录同名的 git 子模块?

转载 作者:太空狗 更新时间:2023-10-29 14:46:46 25 4
gpt4 key购买 nike

我正在尝试将一个目录变成一个子模块,并有效地将它变成一个 git superproject/project,里面有专门的子模块。我有一个“构建”目录(对于我正在制作的内容来说是必需的,因为一些依赖项是封闭源代码的,因此不在 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 搜索,因为我发现的所有结果都是将子模块更改为具有相同目录名称的不同子模块。

最佳答案

确保您首先删除并提交了“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 - 如何添加一个与旧的、已删除的 git 目录同名的 git 子模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22590249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com