Skip to content

Instantly share code, notes, and snippets.

@depressiveRobot
Last active June 6, 2020 13:21
Show Gist options
  • Select an option

  • Save depressiveRobot/626e7066e77da1659c97 to your computer and use it in GitHub Desktop.

Select an option

Save depressiveRobot/626e7066e77da1659c97 to your computer and use it in GitHub Desktop.
bash function to override git init/clone commands
function git() {
if [[ "$1" = "init" ]] # ask for email after init
then
/usr/local/bin/git $@
git-email-prompt.sh
elif [[ "$1" = "clone" ]] # ask for email after clone
then
/usr/local/bin/git $@
if [[ "$3" = "" ]] # no directory given, extract from repo name
then
cd $(echo $2 | awk -F/ '{ print $NF }' | rev | sed 's/tig.//' | rev)
else
cd $3
fi
git-email-prompt.sh
else
/usr/local/bin/git $@
fi
}
@jan-warchol
Copy link

Note that you don't have to enter the repo to set the email - with new enough versions of Git, you can pass configuration options at clone-time. This means you won't have to bother with getting the directory.
See how I solve the email problem here: https://github.com/jan-warchol/dotfiles/blob/devel/bin/git-cln

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment