Pin Loon's Wiki
  • Welcome to my technical notes
  • About Me
  • Linux
    • Basic commands
    • Controller Area Network (CAN)
    • Disk
    • Ethernet
    • Systemd Service
    • SSH
  • Microcontroller / Single Board Computer
    • Debugger / Compiler
    • Raspberry Pi 4
  • Application Platform
    • Docker
    • Docker Compose
  • Application Notes
    • Dataype Overflow
    • Macros
    • Wrong Casting
    • Variadic Function
  • Git
    • Create SSH Keys
    • Git submodule
  • VPN
    • Wireguard Setup on Azure
Powered by GitBook
On this page
  • To add submodule
  • To delete submodule
  • To update submodule
  • References
  1. Git

Git submodule

To add submodule

$ git submodule add <remote_url> <destination_folder>
  • please note that you have to give the full path including the name of folder of the submodule for <destination_folder>

  • <destination_folder> is equivalent to <existing_folder>/<submodule_folder>

  • by default without <destination_folder>, the submodule folder would be created on the current directory

To delete submodule

$ git submodule deinit <path_to_submodule>
Delete the section referring to the submodule from the .gitmodules file
$ git add .gitmodules (to stage changes)
$ git rm --cached <path_to_submodule> (no trailing slash)
$ rm -rf .git/modules/<path_to_submodule>
$ git commit -m "Removed submodule"
$ rm -rf <path_to_submodule>

To update submodule

$  git submodule update --init --recursive

References

PreviousCreate SSH KeysNextWireguard Setup on Azure

Last updated 3 years ago

https://forum.freecodecamp.org/t/how-to-remove-a-submodule-in-git/13228