Skip to content

Instantly share code, notes, and snippets.

@cyrfer
Last active May 24, 2021 20:50
Show Gist options
  • Save cyrfer/d1fa553ea79738b5b178e6c32ba27e70 to your computer and use it in GitHub Desktop.
Save cyrfer/d1fa553ea79738b5b178e6c32ba27e70 to your computer and use it in GitHub Desktop.
git submodule tldr

Notes for working with Git Submodules, taken from:

https://git-scm.com/book/en/v2/Git-Tools-Submodules

Grab submodule dependencies after a fresh clone

  • git submodule init
  • git submodule update

..or alternatively,

  • git submodule update --init

Start using a submodule in a repo

  • git submodule add gitUrlOfProjectToAdd

Get upstream changes

  • git submodule update --remote
  • git submodule update --remote --merge

Track an alternative branch (rather than master)

  • git config -f .gitmodules submodule.SUBMODULEALIAS.branch ALTERNATIVEBRANCHNAME

Check that all submodules have been pushed

  • git push --recurse-submodules=check

To push outstanding changes/updates in submodules, you can cd to each submodule and git push as usual. Alternatively from the top-level, Attempt to push changes in submodules

  • git push --recurse-submodules=on-demand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment