allomov
6/14/2012 - 8:49 PM

Install git from scratch

Install git from scratch

# Install git from (OS X version)
# use this complite script to detect OS:
# https://github.com/coto/server-easy-install/blob/master/lib/core.sh
# for OS X download and install package from here: 
# http://code.google.com/p/git-osx-installer/downloads/

git config --global merge.tool opendiff

# Ignore Carp
git config --global core.excludesfile ~/.gitignore
touch               "$HOME/.gitignore"
echo '.DS_Store' >> "$HOME/.gitignore"
echo '._*'       >> "$HOME/.gitignore"
echo '.svn'      >> "$HOME/.gitignore"
echo '.hg'       >> "$HOME/.gitignore"

# Shortcuts
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch

# Colors? YES!
git config --global color.ui auto

# Personal Setup
git config --global user.name "Your Name"
git config --global user.email your_email@your-domain.com

# Setup Bash Completion
mkdir -p "$HOME/bin"
export PATH="$HOME/bin:$PATH"
echo 'export PATH="$HOME/bin:$PATH"'               >> ~/.bash_profile
cp "/usr/local/git/contrib/completion/git-completion.bash" ~/bin
echo 'source ~/bin/git-completion.bash'            >> ~/.bash_profile

# Add the current Git Branch to your Bash Prompt
echo "PS1='[\u@\h \w\$(__git_ps1 \" (%s)\")]\\$ '" >> ~/.bash_profile


# Generate ssh key
mkdir ~/.ssh; cd !$;
ssh-keygen -t rsa -C "your_email@youremail.com"
# Copies the contents of the id_rsa.pub file to your clipboard
pbcopy < ~/.ssh/id_rsa.pub
echo "RSA key is copied to clipboard, add it to your github account"