User Tools

Site Tools


git:git-full-remove-submodules

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
git:git-full-remove-submodules [2024/05/28 14:07] admingit:git-full-remove-submodules [2025/03/25 17:10] (current) admin
Line 9: Line 9:
 Assume that the submodule is called **submod** and that it's path relative to the root of the git repo is ** external/gits** Assume that the submodule is called **submod** and that it's path relative to the root of the git repo is ** external/gits**
  
-Open a terminal in the root of the git repo, +Open a terminal in the root of the git repo, and edit the **.gitmodules** file to remove the entry 
 +<code> 
 +[submodule "external/gits/submod"
 +path = external/gits/submod 
 +url = https://github.com/user/submod.git 
 +</code> 
 +Remove git tracking of the submodule folder, but keep the files :
 <code bash> <code bash>
 +git rm --cached -r external/gits/submod
 </code> </code>
 +Remove the submodule from git config (all variables are remove using section) :
 +<code bash>
 +git config --remove-section submodule.external/gits/submod
 +</code>
 +stage and commit the changes in .gitmodules
 +<code bash>
 +git add .gitmodules
 +git commit -m "Remove submodule submod"
 +</code>
 +Remove the submodules from .git/modules
 +<code bash>
 +rm -rf .git/modules/external/gits/submod
 +</code>
 +Finally, push the changes to the remote repo
 +<code bash>
 +git push
 +</code>
 +Note that the files are still on the host, to remove them just use rm :
 +<code bash>
 +rm -rf external/gits/submod
 +</code>
 +
 +
  
git/git-full-remove-submodules.1716898066.txt.gz · Last modified: 2024/05/28 14:07 by admin