-
Star
(146)
You must be signed in to star a gist -
Fork
(12)
You must be signed in to fork a gist
-
-
Save kyleturner/1563153 to your computer and use it in GitHub Desktop.
To remove a submodule you need to: | |
Delete the relevant line from the .gitmodules file. | |
Delete the relevant section from .git/config. | |
Run git rm --cached path_to_submodule (no trailing slash). | |
Commit and delete the now untracked submodule files. |
Small correction: “Delete the relevant lines from the .gitmodules file.” (multiple lines, even for one submodule).
This instruction doesn't quite work, at least with Git 1.9.1. The following order seems to be right (source):
- Run
git rm --cached <submodule name>
- Delete the relevant lines from the .gitmodules file.
- Delete the relevant section from .git/config.
- Commit
- Delete the now untracked submodule files.
- Remove directory
.git/modules/<submodule name>
+1 @afiskon
Can the gist be updated?
+1 @afiskon 's solution is working
Still can't believe this isn't superseded by a simple git feature.
+1 for update
+1 @afiskon
+1
+1 @afiskon
+1
+1
Thanks a lot, I'm from google too, and I did it successfully.
Don't forget run git add --all
before git rm --cached path_to_submodule
You don't need to manually prune the submodule from .git/config
if you run git submodule deinit <path-to-submodule>
first. I was using git 2.6.3.
Yep still on google! Thanks
+1
+1
+1
Why doesn't the git team make this simpler?
To delete the relevant section from .git/config
, you can also run:
git submodule deinit <submodule_name>
+1
+1
I also found that I needed to delete the relevant file/folder under .git/modules/<mySubmodule>
.
useful!
According to the git submodule deinit
documents it should be a simple matter of:
git rm path/to/submodule
Seemed to work for me?
"If you really want to remove a submodule from the repository and commit that use git-rm[1] instead. See gitsubmodules[7] for removal options." - https://git-scm.com/docs/git-submodule#git-submodule-deinit-f--force--all--ltpathgt82308203
nice +1
@jfmercer only 2nd on Bing's index because bing sucks
@afiskon +1
+1
git rm -- .gitmodules [ModulesName]
eg.
git rm -- .gitmodules QtSsh
Thanks! This was really handy.