Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete a submodule on GitHub?

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?

like image 679
KEVIN CHEN Avatar asked Jun 15 '26 17:06

KEVIN CHEN


1 Answers

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
like image 191
VonC Avatar answered Jun 17 '26 11:06

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!