Created
January 4, 2014 01:50
-
-
Save TopherGopher/8250435 to your computer and use it in GitHub Desktop.
Just sets the configuration options you need for git on a new machine with a BASH wrapper.
This file contains hidden or 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 | |
#Change these to tailor git to you | |
USER_NAME="Chris Sterling" | |
USER_EMAIL="[email protected]" | |
LOG_MESSAGES_EDITOR="vim" | |
DIFF_PROGRAM="meld" | |
echo "Configure GIT" | |
echo "" | |
echo "What user name would you like to use? ex) John Doe" | |
read $USER_NAME | |
echo "What email address would you like to use? ex) [email protected]" | |
read $USER_EMAIL | |
echo "What program would you like to use to edit log messages? ex) vim" | |
read $LOG_MESSAGES_EDITOR | |
echo "What program would you like to use for diffs? ex) meld" | |
read $DIFF_PROGRAM | |
#Wipe out the old config file, so we don't step on our tails | |
sudo rm ~/.gitconfig | |
#----------------STOP EDITING HERE---------------------# | |
command_exists () | |
{ | |
type "$1" &> /dev/null ; | |
#& runs a command in the background | |
#"> /dev/null" sends any output to nowhere, so we don't get funky text | |
} | |
#Configure user settings which save back to the log | |
git config --global user.name $USER_NAME | |
git config --global user.email $USER_EMAIL | |
#What editor would you like to use for log messages? | |
git config --global core.editor $LOG_MESSAGES_EDITOR | |
#What program would you like to use for diffs? | |
if command_exists $DIFF_PROGRAM ; then | |
git config --global merge.tool $DIFF_PROGRAM | |
else | |
echo "$DIFF_PROGRAM doesn't exists" | |
echo "Would you like to install $DIFF_PROGRAM? (y or n): " | |
read $INSTALL_DIFF | |
if ["$INSTALL_DIFF" == "y"]; then | |
sudo apt-get install $DIFF_PROGRAM | |
git config --global merge.tool $DIFF_PROGRAM | |
else | |
echo "Another program must be used for diffs, the system will use the default\n" | |
fi | |
fi | |
echo "The git settings as they are now will be dumped." | |
#Dump git settings | |
git config --list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment