Last active
December 14, 2015 04:49
-
-
Save polmuz/5030959 to your computer and use it in GitHub Desktop.
Update submodules automatically after checkout when HEAD changes
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
Update submodules automatically after checkout | |
---------------------------------------------- | |
Put the file post-checkout in .git/hooks/ | |
Make it executable | |
(chmod u+x .git/hooks/post-checkout) | |
Never update your submodules manually again (unless something goes horribly wrong)! |
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/sh | |
# Third parameter of post-checkout hook is 1 if the branch changed and | |
# it's 0 if the chechout was to restore the state of a file. We only | |
# want to update the submodules when the HEAD changes. | |
HEAD_CHANGED=$3 | |
if [ $HEAD_CHANGED = "1" ] | |
then | |
echo "Updating Submodules =============" | |
git submodule update --init --recursive | |
echo "Subodules updated ===============" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment