Skip to content

Instantly share code, notes, and snippets.

@jaandrle
Last active May 6, 2022 18:31
Show Gist options
  • Save jaandrle/b4836d72b63a3eefc6126d94c683e5b3 to your computer and use it in GitHub Desktop.
Save jaandrle/b4836d72b63a3eefc6126d94c683e5b3 to your computer and use it in GitHub Desktop.
`git submodule`

git submodules

See documentation Git - Submodules, basic usage below.

Clone parent repo

The default git clone … is not enough, so:

git clone --recurse-submodules TARGET_REPO

…or

git clone TARGET_REPO
git submodule init
git submodule update

Status

git status
git submodules status

Pull

git pull --recurse-submodules

…you can make it default

git config submodule.recurse true

Or:

git submodule foreach git pull

Add

cd TARGET_PATH
git submodule add -b main --depth=1 TARGET_REPO

Remove

git submodule deinit -f TARGET_PATH
rm -rf .git/modules/TARGET_PATH
git rm -rf TARGET_PATH

TARGET_PATH can be found via ##Status, source: Remove A Submodule In Git | Rm -rf - Javaexercise. … define alias in your .gitconfig:

rm-submodule = !git submodule deinit -f $1 && rm -rf .git/modules/$1 && git rm -rf $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment