我想在我的项目中添加一个Git子模块,具体来说是ShareKit。我的项目是一个Git仓库,当我尝试输入以下命令时:
git submodule add git://github.com/ShareKit/ShareKit.git Submodules/ShareKit
在终端中输入时,我收到了一个错误提示,说子模块已经存在。我猜我一段时间前将其添加到该项目中,最终并未使用它并从项目目录中删除它(可能只是删除了子模块文件夹)。所以我尝试执行以下操作:
git rm --cached Submodules/ShareKit
根据如何删除Git子模块,现在当我尝试使用第一个代码添加子模块时,会出现以下情况:
A git directory for 'Submodules/ShareKit' is found locally with remote(s):
origin git://github.com/ShareKit/ShareKit.git
If you want to reuse this local git directory instead of cloning again from
git://github.com/ShareKit/ShareKit.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.
我不确定该怎么办。我对git相当新,我需要在我的项目中使用它 - 有没有办法只是清除项目中所有与git相关的内容,然后重新开始?我可以用一个新项目来做这件事,但除此之外,它已经基本完成了,如果重新开始并复制所有内容将非常耗时。我已经在测试应用程序中成功安装了ShareKit,是否有任何理由我不能将那个文件夹中的所有ShareKit文件复制到我需要它们的文件夹中?
编辑:我已经尝试过了。
git submodule deinit Submodules/ShareKit
这让我产生了这个错误:
error: pathspec 'Submodules/ShareKit' did not match any file(s) known to git.
Did you forget to 'git add'?
看起来它卡在某种奇怪的状态下,既坚持子模块存在,又同时不存在。我正在使用终端将子模块添加到Xcode项目中,以免混淆。