Skip to content

Instantly share code, notes, and snippets.

@ahmadazimi
Forked from digitaljhelms/post-rewrite
Created December 1, 2015 13:32
Show Gist options
  • Save ahmadazimi/666b12a59d94ee063d62 to your computer and use it in GitHub Desktop.
Save ahmadazimi/666b12a59d94ee063d62 to your computer and use it in GitHub Desktop.
Git hook to call `git submodule update` automatically.
#!/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