Created
September 22, 2014 14:49
-
-
Save digitaljhelms/f74eaf56835262d6bf3f to your computer and use it in GitHub Desktop.
Git hook to call `git submodule update` automatically.
This file contains hidden or 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/sh | |
echo "[post-rewrite hook: $1]" | |
# quick script to call "git submodule update" automatically if the | |
# .gitmodules file is changed | |
changedfiles=( `git diff-tree --no-commit-id --name-only HEAD@{1} HEAD` ) | |
if [[ "${changedfiles[*]}" =~ ".gitmodules" ]]; then | |
echo "initializing & updating submodule(s)" | |
git submodule update --init --recursive | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure why, but (three years later) I tried to implement this as a post-rewrite hook and it didn't work. It does work fine as post-merge, though. Git version issue maybe?