Skip to content

Instantly share code, notes, and snippets.

@gjask
Last active December 13, 2016 16:21
Show Gist options
  • Save gjask/d7305ac8b6b4419292a485d4cfbd6029 to your computer and use it in GitHub Desktop.
Save gjask/d7305ac8b6b4419292a485d4cfbd6029 to your computer and use it in GitHub Desktop.
#!/bin/bash
name='John Doe'
email='john.doe@email.com'
path=$( dirname $0 )
while [ -n "$1" ]; do
case "$1" in
-u)
name="$2"
shift 2
;;
-e)
email="$2"
shift 2
;;
*)
repos="$repos $1"
shift
;;
esac
done
[ -n "$repos" ] || repos=$path/*
err(){
echo $* >&2
exit 1
}
set_identity(){
repo=$1
git -C $repo config user.name "$name" || err 'Git local config edit failed!'
git -C $repo config user.email "$email" || err 'Git local config edit failed!'
}
for repo in $repos; do
if ! [ -d $repo/.git ]; then
echo "skipping: $repo" >&2
continue
fi
set_identity $repo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment