简体   繁体   English

git submodule add将不会添加存储库

[英]git submodule add will not add repository

I had a project form a remote repo that was a submodule in my project. 我有一个来自远程仓库的项目,该项目是我项目的子模块。 I forked that remote project, removed the old submodule, and then tried to add my forked copy. 我分叉了该远程项目,删除了旧的子模块,然后尝试添加我的分叉副本。 This doesn't work. 这行不通。

What I did was: 我所做的是:

 git submodule deinit path/to/sub
 git rm /path/to/sub
 git push origin mybranch

then 然后

 git submodule add url_of_forked_project_in_my_repo path/to/sub

I get some weird message about the repo being local, that I should use --force or --name, and the end effect of trying any of those is that my local fork does not update with any changes I make, and the references remain to the old submodule HEAD. 我收到一些关于回购在本地的奇怪信息,我应该使用--force或--name,尝试使用其中任何一个的最终结果是我的本地fork不会随着我所做的任何更改而更新,并且引用仍然存在到旧的子模块HEAD。

The message is: 消息是:

A git directory for 'path/to/sub' is found locally with remote(s): origin git://github.com/SomeoneElse/project If you want to reuse this local git directory instead of cloning again from git@github.com:myrepo/project.git use the '--force' option. 可以在本地找到带有远程目录的“ path / to / sub”的git目录:origin git://github.com/SomeoneElse/project如果要重用此本地git目录,而不是再次从git @ github克隆。 com:myrepo / project.git使用'--force'选项。 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目录不是正确的仓库,或者您不确定这意味着什么,请使用'--name'选项选择另一个名称。

If I use the --force option, I'm able to get the submodule, but references don't seem to update and changes I make in my the submodule in my main project don't propagate anywhere: is that what's meant by local? 如果使用--force选项,则可以获取子模块,但是引用似乎无法更新,并且我在主项目的子模块中所做的更改不会传播到任何地方:这是local的意思。 ?

At any rate, I just want a normal, run of the mill submodule, where updating in my main project's copy creates changes in references and so on. 无论如何,我只希望正常运行mill子模块,在该子模块中,对我的主项目副本进行更新会创建引用的更改,依此类推。

Any help would be appreciated. 任何帮助,将不胜感激。

You're not alone. 你不是一个人。 I troubleshooted the problem by following this answer . 我按照以下答案解决了问题。 Do keep in mind deleting not only the corresponding snippet in the .gitmodule file is necessary but also the subdirectory under .git/modules . 请记住,不仅需要删除.gitmodule文件中的相应代码段,还需要删除.git/modules下的子目录。

If you're versioning your repo, like dotfile as me, using links in a folder, you'll be nevigated to the related directory for the module which should be deleted. 如果要使用文件夹中的链接来对存储库进行版本控制(例如,像dotfile一样),则将导航至应删除模块的相关目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM