git:git-full-remove-submodules
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
git:git-full-remove-submodules [2024/05/28 13:55] – admin | git:git-full-remove-submodules [2025/03/25 17:10] (current) – admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
Back to [[git: | Back to [[git: | ||
- | If you want to fully remove a submodule, | + | If you want to fully remove a submodule, |
- | - remove the submodule entry from the .gitmodules file in the root of the main git repo | + | |
- | - remove the variables associated to the submodule | + | |
+ | * remove the description in ./ | ||
+ | * remove the folder containing | ||
+ | Assume that the submodule is called **submod** and that it's path relative to the root of the git repo is ** external/ | ||
+ | |||
+ | Open a terminal in the root of the git repo, and edit the **.gitmodules** file to remove the entry | ||
+ | < | ||
+ | [submodule " | ||
+ | path = external/ | ||
+ | url = https:// | ||
+ | </ | ||
+ | Remove git tracking of the submodule folder, but keep the files : | ||
<code bash> | <code bash> | ||
- | git config | + | git rm --cached -r external/ |
- | <\code> | + | </ |
+ | Remove the submodule from git config | ||
+ | < | ||
+ | git config --remove-section submodule.external/ | ||
+ | </ | ||
+ | stage and commit the changes in .gitmodules | ||
+ | <code bash> | ||
+ | git add .gitmodules | ||
+ | git commit -m " | ||
+ | </ | ||
+ | Remove the submodules from .git/ | ||
+ | <code bash> | ||
+ | rm -rf .git/ | ||
+ | </ | ||
+ | Finally, push the changes to the remote repo | ||
+ | <code bash> | ||
+ | git push | ||
+ | </ | ||
+ | Note that the files are still on the host, to remove them just use rm : | ||
+ | <code bash> | ||
+ | rm -rf external/ | ||
+ | </ | ||
+ | |||
git/git-full-remove-submodules.1716897351.txt.gz · Last modified: 2024/05/28 13:55 by admin