Last active
April 6, 2018 14:25
-
-
Save atillay/08a650ed924e4980af4799f1b24ae655 to your computer and use it in GitHub Desktop.
Git post-commit hook to save daily activity into a file
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/sh | |
# Setup : https://coderwall.com/p/jp7d5q/create-a-global-git-commit-hook | |
today=$(date +%d-%m-%Y) | |
log_file_name=”git-commits-$today.txt” | |
log_dir=”$HOME/Desktop” | |
log_file_path=”$log_dir/$log_file_name” | |
remote=$(git config — get remote.origin.url) | |
if [ -z “$remote” ]; then | |
remote=”no_origin_remote” | |
fi | |
branch=$(git rev-parse — abbrev-ref HEAD) | |
commit_message=$(git log -1 — pretty=’%s’) | |
commit_date=$(git log -1 — pretty=’%ai’ | cut -f1 -d”+”) | |
message=”$commit_date | $branch@$remote | $commit_message” | |
echo $message$’\r’ >> $log_file_path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment