Skip to content

Instantly share code, notes, and snippets.

@kreeger
Last active November 30, 2021 08:15
Show Gist options
  • Save kreeger/5871439 to your computer and use it in GitHub Desktop.
Save kreeger/5871439 to your computer and use it in GitHub Desktop.
A post-checkout hook for running a pod install after a git checkout event.
#!/bin/sh
if [ $1 = 0000000000000000000000000000000000000000 ]; then
old=4b825dc642cb6eb9a060e54bf8d69288fbee4904
else
old=$1
fi
if [ -f Podfile ] && command -v pod install >/dev/null &&
git diff --name-only $old $2 | egrep -q '^Podfile$'
then
(unset GIT_DIR; exec pod install) | grep -v '^Using ' | grep -v ' is complete'
true
fi

pod-install-post-checkout

Keep your installed pods up-to-date between branch checkouts! This is a git post-checkout hook for running a pod install whenever a checkout event happens in your local working git repository.

Thanks to Soroush Khanlou for the inspiration and Tim Pope for his blog post for doing this with Bundler.

Install using…

curl https://gist.github.com/kreeger/5871439/raw > .git/hooks/post-checkout
chmod +x .git/hooks/post-checkout

If you're a user of Guard, checkout my Guard plugin that polls the Podfile for changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment