Created
December 8, 2015 17:35
-
-
Save bgamari/919e1279c1615b9b1cb4 to your computer and use it in GitHub Desktop.
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
#!/bin/bash -e | |
usage() { | |
echo "Usage: $0 [<ref>]" | |
echo | |
echo "Make the submodules in a repository match the given ref (e.g. a commit, branch, or tag)." | |
exit 1 | |
} | |
ref="$1" | |
if [ -z "$ref" ]; then ref="master"; fi | |
sha="$(git rev-parse $ref)" || usage | |
echo "Checking out submodules for $ref ($sha)" | |
git submodule foreach "(git -C \$toplevel checkout $sha \$path && git -C \$toplevel add \$path) || exit 0" | |
echo "Done." | |
git status | |
echo "Changes for preceeding submodules are staged, run 'git commit' to commit." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment