Sometimes when working on a PHP project where there are a lot of branches potentially sitting on incompatible packages, it can be a pain to always remember to manually run composer i or whatever docker alternative or alias one might be using. I tried to modify this stack overflow https://stackoverflow.com/a/20892987/1972509 to see if this could be comfortably automated via git hooks.
Here's the final script: #!/bin/bash set -e prevHEAD=$1 newHEAD=$2 if ["$newHEAD"!= "$prevHEAD"]; then printf "Post-checkout 'composer install' hook active.\n" composer i >/dev/null 2>&1 & fi
You should be able to see a brief peak in the CPU usage in the very least after every checkout: $ git checkout - Switched to branch 'somebranch' Post-checkout 'composer install' hook active.