Created
February 27, 2020 00:53
-
-
Save Irfan434/e2db6ba086ad83aa87398d0a49d50ab3 to your computer and use it in GitHub Desktop.
Git hook for logging branch checkouts
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
# Instructions | |
# ======================================================================== | |
# 1. Copy this file to .git/hooks/post-checkout (remove the .sh extension) | |
# | |
# 2. Set the destination for the logs, e.g. | |
# - export CHECKOUT_LOG='~/checkout.log' | |
# - also add it as a Windows environment variable with the full filepath | |
# | |
# 3. Watch the logs update every time you checkout a branch with | |
# tail -f $CHECKOUT_LOG | |
# | |
# 4. Example output: | |
# 1581465462 my-repo branch-name -- Checked out on Wed, Feb 12, 2020 10:57:42 AM | |
echo `date +%s; | |
basename \`pwd\`; | |
git branch --show-current; | |
echo ' -- Checked out on'; | |
date` \ | |
>> "$CHECKOUT_LOG" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment