1

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.

3
  • Check out this: stackoverflow.com/questions/913701/… Perhaps you can fix the problem by editing the .gitmodules file in the root of your repository manually. Commented Nov 25, 2014 at 20:28
  • That is indeed what I ended up doing. Good to know I'm not the only one to have resorted to such means! Commented Nov 25, 2014 at 20:29
  • Leaving unanswered in case someone has a better solution. As mentioned above, I edited the .gitmodules file to point to the proper repo. When fetching, others on my team had to git submodule sync to make everything jive. Commented Nov 25, 2014 at 20:31

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.