3

I accidentally created a submodule on GitHub after forcing a commit. For some reason, I can't wipe my repository and start over so I need some way to delete the submodule so I can recommit. Is there any way I can delete the submodule through my terminal?

KEVIN CHEN
  • 33
  • 1
  • 3

1 Answers1

7

If it actually is a submodule, meaning your GitHub repo also have a .gitmodules files recording the associated path of that submodule, see my answer here:

1. git submodule deinit -f -- a/submodule    
2. rm -rf .git/modules/a/submodule
3. git rm -f a/submodule

Then commit and push.

But if it is a simple gitlink, displayed as a grayed folder on GitHub, as shown here, then just remove it locally and push:

git rm -f a/submodule
git commit -m "remove submodule gitlink"
git push
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250