Skip to content

Instantly share code, notes, and snippets.

@htr3n
Last active July 27, 2018 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save htr3n/6bef6e54f0552573cab3e6cbac364c1b to your computer and use it in GitHub Desktop.
Save htr3n/6bef6e54f0552573cab3e6cbac364c1b to your computer and use it in GitHub Desktop.
Remove git submodule

https://stackoverflow.com/a/16162000/339302

# 0. 
mv a/submodule a/submodule_tmp
#1. 
git submodule deinit -f -- a/submodule
#2. 
rm -rf .git/modules/a/submodule
#3. 
git rm -f a/submodule
# Note: a/submodule (no trailing slash)

# or, if you want to leave it in your working tree and have done step 0
# 3.   
git rm --cached a/submodule
# 3bis 
mv a/submodule_tmp a/submodule

https://stackoverflow.com/a/1260982/339302

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes git add .gitmodules
  3. Delete the relevant section from .git/config.
  4. Run git rm --cached path_to_submodule (no trailing slash)
  5. Run rm -rf .git/modules/path_to_submodule (this step is no longer needed due to the 4th step)
  6. Commit git commit -m "Removed submodule <name>"
  7. Delete the now untracked submodule files rm -rf path_to_submodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment