Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save douglasjarquin/61b6fb2a037142bae5ace44bd7bcce58 to your computer and use it in GitHub Desktop.
Save douglasjarquin/61b6fb2a037142bae5ace44bd7bcce58 to your computer and use it in GitHub Desktop.
git hook for revision and branch version file
#!/usr/bin/env bash
# Automatically generate a file with git branch and revision info
#
# Example:
# a830382
#
# Install:
# $ cp git-create-revisioninfo-hook.sh .git/hooks/post-commit
# $ cp git-create-revisioninfo-hook.sh .git/hooks/post-checkout
# $ cp git-create-revisioninfo-hook.sh .git/hooks/post-merge
# $ chmod +x .git/hooks/post-*
exec 1>&2
shorthash=`git log --pretty=format:'%h' -n 1`
echo "$shorthash" > revision.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment