Last active
November 12, 2015 18:07
-
-
Save orottier/132f6c472dbc6aa9407f to your computer and use it in GitHub Desktop.
Pre Commit hook, proper stashing with unstash using bash traps (in case of errors halfway)
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/bash | |
# | |
# An example hook script to verify what is about to be committed. | |
# Called by "git commit" with no arguments. The hook should | |
# exit with non-zero status after issuing an appropriate message if | |
# it wants to stop the commit. | |
git stash -u --keep-index | |
trap "git stash pop --quiet --index; exit 1" SIGINT SIGTERM | |
# your checks, only working on staged changes | |
git stash pop --quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment