A submodule can simply be deleted using two commands sequentially git rm <submodule path> && git commit
like below
[email protected]:~/youtube-dl$ git rm -f requests
rm 'requests'
[email protected]:~/youtube-dl$ git commit -m "Deleted submodule"
[master ddba8654e] Deleted submodule
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 .gitmodules
Code language: Bash (bash)
The section in .gitmodules
along with the submodule working directory will be removed.
However, its history in Git directory ($GIT_DIR
, which is usually .git
) is keep around so that you can undo your changes using git revert
or checkout past commits without fetching from the original repository.
To completely delete all traces of the submodules, you can manually delete .git/modules/module_name
or $GIT_DIR/modules/module_name/
in case you've changed $GIT_DIR
to your own value.
A list of steps for you guys who are in need of a quick solution :
- Give the submodule a name
submodule="module_name
" - Delete
.gitmodules
section and submodule directory usinggit rm "$submodule"
- Delete submodule's directory in
$GIT_DIR
withrm -rf ".git/modules/$submodule"
- Commit the changes
git commit -m "Remove submodule $submodule"
Related posts:
You should not use or withrouter() outside a in React Router
How to install GNOME Desktop in Debian
How to install Timeshift in Ubuntu
Notepad++ Extended Search
[SOLVED] Unable to correct problems, you have held broken packages
VSCode Command Palette
"error: cannot lock ref" - what to do?
IntelliSense doesn't work in VSCode - possible fixes
Click to rate this post!
[Total: 46 Average: 4.9]
You have already voted for this article