Created
August 29, 2016 18:23
-
-
Save tmhpfnr/9b56f7a0a469b12a8d6a5ad55152508f to your computer and use it in GitHub Desktop.
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 | |
# -------------------------------------------------------- | |
# Installation | |
# $ git config --global init.templatedir '~/.git-templates' # setup global templatedir | |
# $ mkdir -p ~/.git-templates/hooks # create hooks direcotry | |
# $ touch ~/.git-templates/hooks/pre-commit # copy & paste this content into ~/.git-templates/hooks/pre-commit | |
# $ chmod a+x ~/.git-templates/hooks/pre-commit | |
# $ git init # reinitialized existing git repositories | |
# -------------------------------------------------------- | |
# allows us to read user input below, assigns stdin to keyboard | |
exec < /dev/tty | |
ask_for_email() { | |
read -p "Please provide user.email: " email | |
git config --local user.email $email | |
} | |
if git rev-parse --git-dir > /dev/null 2>&1; then | |
if ! git config --local user.email > /dev/null 2>&1; then | |
while true; do | |
read -p "Do you wish to use the global user.email?(y/n) " yn | |
case $yn in | |
[Yy]* ) git config --local user.email $(git config --global --get user.email); break;; | |
[Nn]* ) ask_for_email; break;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment