Tag - git

git    2016-10-20 02:41:23    274    0    0

0. Add a submodule

  1. git submodule add [-b <branch>]<repository> [<path>]
  2. git submodule init
  3. git submodule update

1. Remove config entries:

  1. git config -f .git/config --remove-section submodule.$submodulepath
  2. git config -f .gitmodules --remove-section submodule.$submodulepath

2. Remove directory from index:

  1. git rm --cached $submodulepath

3. Commit

4. Delete unused files:

  1. rm -rf $submodulepath
  2. rm -rf .git/modules/$submodulepath

Background

When you do git submodule add, it only adds it to .gitmodules, but once you did git submodule init, it added to .git/config.

So if you wish to remove the modules, but be able to restore it quickly, then do just this:

  1. git rm --cached $submodulepath
  2. git config -f .git/config --remove-section submodule.$submodulepath

It is a good idea to do git rebase HEAD first and git commit at the end, if you put this in a script.