Last active
April 28, 2017 05:25
-
-
Save amgohan/a0c8d8f0368332de192c6a4f9a247ee8 to your computer and use it in GitHub Desktop.
add user and email automatically to cloned project
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/bash | |
echo "enter your git user.name" | |
read user_name | |
echo "enter your git user.email" | |
read user_email | |
cat > /bin/gitclone <<- EOM | |
#!/bin/bash | |
set -e | |
git clone \$1 | |
PROJECT_NAME=\$(echo \$1 | sed -n 's#.*/\([^.]*\)\.git#\1#p') | |
echo "\$PROJECT_NAME cloned" | |
cd \$PROJECT_NAME | |
git config user.name "${user_name}" | |
git config user.email "${user_email}" | |
EOM | |
chmod +rx /bin/gitclone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Motivation
I have my work account configured as global user and email. But for my own freetime projects I add the user and email manually to the project scope. But when I forget to add them I commit with my work account into my own repos 👎 .
This script helps me to add my name and email when I clone a new project for the first time.
How to install
Usage
this will add the section [user] in your project .git