Skip to content

Instantly share code, notes, and snippets.

@blachniet
Last active November 18, 2017 00:03
Show Gist options
  • Save blachniet/955ba45920f4d8461bb43d120c10eb13 to your computer and use it in GitHub Desktop.
Save blachniet/955ba45920f4d8461bb43d120c10eb13 to your computer and use it in GitHub Desktop.
Git post-update hook: After $TARGET_REF is pushed, write the contents of $FILE to $DEST.
#!/bin/sh
#
# After $TARGET_REF is pushed, write the
# contents of $FILE to $DEST.
#
# To enable this hook in a bare git repo
# 1. place it in the hooks/ directory
# 2. rename it to "post-update"
# 3. chmod +x post-update
TARGET_REF=refs/heads/master
FILE=README.md
DEST=/tmp/README.md
for ref in "$@"
do
if [[ $ref == $TARGET_REF ]]; then
echo "'$TARGET_REF' updated, copying '$FILE' to '$DEST'"
git show $TARGET_REF:$FILE > $DEST
echo "Done"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment