All I want to do is. . .

. . .use submodules in git.

OS:
Tags:

Helpful commands for working with git submodules.
Contributors: anschwa Updated: 10/10/15

How to use submodules in git.

Cloning Repository with Submodules

There are two ways to do this:

First, clone the repository without fetching the submodule's files:

git clone <repository>

Then, fetch all the submodule data:

git submodule init
git submodule update

Or, you can simply do this all at once with:

git clone --recursive <repository>

Removing Submodule

Taken from: David Walsh's Remove a Submodule within git

  1. Delete the relevant section from the .gitmodules file. The section would look similar to:
[submodule "vendor"]
    path = vendor
    url = git://github.com/some-user/some-repo.git
  1. Stage the .gitmodules changes via command line using:
git add .gitmodules
  1. Delete the relevant section from .git/config, which will look like:
[submodule "vendor"]
    url = git://github.com/some-user/some-repo.git
  1. Run:
git rm --cached path/to/submodule

Don't include a trailing slash, that will lead to an error.

  1. Run:
rm -rf .git/modules/submodule_name
  1. Commit the change:

  2. Delete the now untracked submodule files

rm -rf path/to/submodule

Raw: use-git-submodule.md


If you have suggestions, corrections, or content to contribute, fork us at our Github repo or open an issue.

Licensed under the CC-SA.