Last active
February 8, 2018 10:50
-
-
Save jagomf/b29171919096f493d23cadb8f43796ae to your computer and use it in GitHub Desktop.
Git submodules best practices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Clone repository with submodules automatically: | |
git clone --recursive [email protected]:name/repo.git | |
// Initialize submodules after regular cloning: | |
git submodule update --init | |
// Make submodules to track their respective remote branches (instead of being in detached HEAD state): | |
git submodule foreach -q --recursive 'git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch || echo master)' | |
// Display status of submodules when git status is invoked: | |
git config --global status.submoduleSummary true | |
// Script for pulling the main repo and updating the sumodules automatically: | |
#!/usr/bin/env bash | |
git pull "$@" && | |
git submodule sync --recursive && | |
git submodule update --init --recursive | |
// Further reading | |
https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment