Git Submodule Deinit

The most recent version of Git, 1.8.3, comes with a new and useful command for submodules: git submodule deinit. Previously if you wanted to remove a submodule from a project you needed to manually take it out of the .git/config file of the parent repository, and the .gitmodules file. The new command does this for you. So for example:

$ git submodule deinit FooLib

This command tells Git to stop paying attention to the FooLib submodule. That means commands like git submodule sync will ignore it. This will not remove the submodule from disk, nor will create a commit removing the submodule. That is so you can reintegrate the submodule later if needed by using the command git submodule init FooLib. If you want to delete a submodule and make that deletion part of the project history then you need to use git rm -r FooLib instead.

So use git rm if you want to truly remove a submodule from a project. But if you just want to make Git shut-up and leave a submodule alone then git submodule deinit is your new best friend.


One thought on “Git Submodule Deinit

Add Your Thoughts

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s