Reputation: 509
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.
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 [email protected]:myrepo/project.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.
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?
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.
Any help would be appreciated.
Upvotes: 1
Views: 165
Reputation: 7150
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
.
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.
Upvotes: 1