Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Last active March 29, 2024 22:43
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Noitidart/7af2e120bb83e2be9aa4cc3ca0a37722 to your computer and use it in GitHub Desktop.
Save Noitidart/7af2e120bb83e2be9aa4cc3ca0a37722 to your computer and use it in GitHub Desktop.
Tips for working with git submodules

Tips for Working With git Submodules

Cloning Repo with Submodules

  1. Use the --recursive flag:

     git clone https://github.com/aikiframework/json.git --recursive
    

    However if you cannot, as Github desktop app on clone does not use this flag, then do this after clone:

     git submodule update --init
    
  2. You will not be able to do a git pull by cding into the submodule directory. You will get You are not currently on a branch.. To let it know you really are on master, cd into each submodule directory and then:

     git checkout master
    

Removing/Deleting a Submodule

Source: todo
  1. Remove the submodule entry from .git/config:

     git submodule deinit path/to/submodule
    
  2. Delete the submodule directory from the superproject's .git/modules directory

     rm -rf .git/modules/path/to/submodule
    
  3. Delete the submodule directory located at path/to/submodule

     rm -rf path/to/submodule
    
  4. Remove the entry in .gitmodules file BY HAND

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment