kdsch.org · about · rss

2023 May 17

Work with Git submodules

Add a submodule at a specific commit

git submodule add https://git.sr.ht/~kdsch/bl
git -C bl/ checkout 113632ca
git add bl/
git commit -m 'add bl submodule at 113632ca'

List submodules

git submodule

Change the version of a submodule

git -C bl/ checkout f81b3582
git add bl/
git commit -m 'bl: update to f81b3582'

Change the remote of a submodule

git submodule set-url bl git@git.sr.ht:~kdsch/bl
git add .gitmodules
git commit -m 'bl: use ssh protocol for the remote'

Note git submodule set-url <path> will not work correctly if the path contains a trailing slash.

Delete a submodule

This used to require several more commands.

git rm bl/
git commit -m 'delete bl submodule'


Discuss and submit patches for this page by emailing my public inbox. Please note the etiquette guidelines.

© 2023 Karl Schultheisz — source