Search code examples
gitgit-submodules

Removing submodule and keeping files?


I am using a plugin that helped me tremendously but uses a submodule. When I tried to push it to remote I learned that a submodule is just a reference to another repo. I want to just have the files in my own repo and push them to remote.

All attempts from other SO articles have failed so far.

Here is my .submodules folder:

[submodule "Vendor/Opauth"]
    path = Vendor/Opauth
    url = git://github.com/opauth/opauth.git

Here is my filesystem for this specific area: enter image description here

How do I remove the submodule and then keep the Vendor/Opauth files?


Solution

  • As I mentioned in "How do I remove a Git submodule?", you should deinit and remove the submodule (assuming here git 1.8.3+).

    git submodule deinit Vendor/Opauth
    git rm --cached Vendor/Opauth
    rm -Rf .git/modules/Opauth
    

    The --cached ensure that you keep the files on the disk.