Git submodules cheat sheet
Note: run these from the top level of your repo.
Clone a repo with submodules:
1 2 |
$ git clone git@bitbucket.org:akrabat/dotvim.git .vim $ git submodule update --init |
View status of all submodules:
1 |
$ git submodule status |
Update submodules after switching branches:
1 |
$ git submodule update |
Add a submodule:
1 |
$ git submodule add git://github.com/tpope/vim-sensible.git bundle/vim-sensible |
Update all submodules to latest remote version
1 2 |
$ git submodule update --remote --merge $ git commit -m "Update submodules" |
Update a specific submodule to the latest version (explicit method):
1 2 3 4 5 |
cd bundle/vim-sensible git pull origin master cd ../.. git add bundle/vim-sensible git commit -m "update vim-sensible" |
Remove a submodule:
1 2 3 4 |
edit .gitmodules and remove this submodule's section $ git rm --cached bundle/vim-sensible $ rm -rf bundle/vim-sensible $ git commit -m "Remove vim-sensible" |
or
1 2 3 |
git submodule deinit bundle/vim-sensible git rm bundle/vim-sensible git commit -m "Remove vim-sensible" |
Docs: