ZSH: auto set git user.email for work repos
WORK_REPO=corp
WORK_EMAIL=user@corp.com
function _git_work_email {
if test -d .git; then
if test "$(git remote -v | grep $WORK_REPO)"; then
git config --local user.email $WORK_EMAIL
fi
fi
}
chpwd_functions=(${chpwd_functions[@]} "_git_work_email")
Written by Joshua Mervine
Related protips
1 Response
git config --local user.email
have to be done just once per clone, as the setting is stored in .git/config
. But instead you are doing it every time you enter the repo.
It would be better to do that in a git post-checkout
hook.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Zsh
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#