How to remove submodule from Git

Photo by Pankaj Patel on Unsplash

Git allows you to include other repositories for your project as a submodule, however, I've encountered an errors. To remove them cleanly, follow these steps below.

  1. Open root directory of project
    cd path/to/project
  2. Move module to a temporary directory
    mv path/to/[module] path/to/[module]_tmp
  3. De-initialize submodule
    git submodule deinit -f -- path/to/[module]
  4. Remove from Git modules
    rm -rf .git/modules/path/to/[module]
  5. Remove from Git repository
    git rm -rf path/to/[module]
  6. Remove temporary directory
    rm -rf path/to/[module]_tmp
Tags

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.