Skip to content

Instantly share code, notes, and snippets.

@terabyte
Created June 15, 2017 19:00
Show Gist options
  • Save terabyte/45927042317805b3f1f4487de74a9420 to your computer and use it in GitHub Desktop.
Save terabyte/45927042317805b3f1f4487de74a9420 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# usage: set-git-author.sh [HOME|WORK] /path/to/.git/config
# example crontab:
# find /home/cmyers/projects/cloudera -type f -path '*/.git/config' -exec /home/cmyers/bin/set-git-author.sh WORK {} \;
# find /home/cmyers/projects -type f -path '*/.git/config' -not -path '*/cloudera/*' -exec /home/cmyers/bin/set-git-author.sh HOME {} \;
TYPE="$1"
GIT_PATH="$(dirname $2)"
GIT_NAME="Carl Myers"
if [[ "$TYPE" == "HOME" ]]; then
GIT_EMAIL="cmyers@cmyers.org"
elif [[ "$TYPE" == "WORK" ]]; then
GIT_EMAIL="cmyers@cloudera.com"
else
echo "Invalid author type" 1>&2
exit 1
fi
#echo "GIT_PATH=$GIT_PATH GITNAME=$GIT_NAME GITEMAIL=$GIT_EMAIL"
#exit 0
git --git-dir="$GIT_PATH" config user.name "$GIT_NAME"
git --git-dir="$GIT_PATH" config user.email "$GIT_EMAIL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment