Hello,
I accidentally created my submodule at the wrong location. I want to delete it and re-add it correctly. However, I can't figure out how to delete it.
Any help would be appreciated.Thank you
For anyone else coming by later, I ended up finding this ...
"Since git 1.8.5, git mv old/submod new/submod works as expected and does all the plumbing for you. You might want to use git 1.9.3 or newer, because it includes fixes for submodule moving."via https://stackoverflow.com/questions/4604486/how-do-i-move-an-existing-git-submodule-within-a-git-repository
git mv old/submod new/submod
Hi Lester,
The best way to completely remove a submodule would be using the command line, you can follow the steps:
.gitmodules
git add .gitmodules
.git/config
git rm --cached path_to_submodule
rm -rf .git/modules/path_to_submodule
git commit -m "Removed submodule <name>"
rm -rf path_to_submodule
You can also find different approaches <a href="https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule" target="_blank" rel="nofollow noopener noreferrer">in this thread</a>.
Hope that helps!
Ana
Hi @Ana Retamal,
I have a couple follow up questions.
1) My real issue is that I added the submodule to the incorrect path. I was planning on deleting the submodule and then re-creating it. Is it instead possible to move the submodule? I noticed the paths in the .gitmodules; can I edit those? (FYI, I tried this before asking and it didn't work, but maybe I am doing something wrong)2) I have multiple submodules, and after editing the .gitmodules file, by hand, all my other submodules disappear from sourcetree. Is that expected behavior? I have not completed your steps because I wanted to wait for an answer to this before proceeding too far.Thank you for the helpLester
I was wondering if you had any info regarding those follow up questions I posted above? I have still held off from continuing the process, because I am not entirely sure if #2 is going to cause more trouble for me or not.
Thank youLester
Hi @Ana Retamal,I apologize for the repeated pings. I speculate that maybe this was lost over the holiday breaks. I am having issues with your instructions, and had some follow up questions.1) My real issue is that I added the submodule to the incorrect path. I was planning on deleting the submodule and then re-creating it. Is it instead possible to move the submodule? I noticed the paths in the .gitmodules; can I edit those? (FYI, I tried this before asking and it didn't work, but maybe I am doing something wrong)2) I have multiple submodules, and after editing the .gitmodules file, by hand, all my other submodules disappear from sourcetree. Is that expected behavior? I have not completed your steps because I wanted to wait for an answer to this before proceeding too far.Thank you for the assistanceLester
It looks like you're new here. Sign in or register to get started.