Skip to content

Instantly share code, notes, and snippets.

@leonardofaria
Forked from ma11hew28/.gitconfig
Created July 11, 2011 00:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonardofaria/1075134 to your computer and use it in GitHub Desktop.
Save leonardofaria/1075134 to your computer and use it in GitHub Desktop.
Bash Script to Install Git on Mac OS X 10.6 (Snow Leopard) Intel x86 (32 bit)
[user]
name = Matt Di Pasquale
email = my@fake-email.com
[alias]
br = branch
ci = commit -am
co = checkout
df = diff
lg = log
ll = log -p
rb = rebase
rbc = rebase --continue
re = remote
st = status
up = pull --rebase
[core]
excludesfile = ~/.gitignore
[branch "master"]
remote = origin
merge = refs/heads/master
[rerere]
enabled = 1
# git-ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
# general
.DS_Store
.localized
Thumbs.db
*.swp
*.out
# rails
config/database.yml
config/*.sphinx.conf
coverage/*
doc/api
doc/app
db/*sqlite3
db/sphinx
log/*.log
public/javascripts/*
!public/javascripts/application.js
public/cache/**/*
tmp/*
#!/bin/bash
# Install Git on Mac OS X 10.6 (Snow Leopard) Intel x86 (32 or 64 bit)
# by "Matt Di Pasquale" http://www.mattdipasquale.com/
#
# UPDATE: Install Homebrew and run `brew install git` instead of this script.
# Trust me. It's the best. It has a strict policy of only installing files into
# one directory (/usr/local by default). You could just uninstall everything by
# doing `rm -rf /usr/local`. There are many other great things. It just works!
#
# About: This shell script installs the latest version of Git into /usr/local
# because that's the standard directory to install additional software and is
# also recommended by Homebrew (http://mxcl.github.com/homebrew/). This script
# is very similar to the Homebrew Git Formula:
# https://github.com/mxcl/homebrew/blob/master/Library/Formula/git.rb
#
# Note: If you have mysql installed in /usr/local (which you can determine by
# running `which mysql`), I recommend stopping mysql before running this script.
# If mysql is installed in /usr/local but /usr/local/mysql/data doesn't exist,
# manually run `sudo chown -R _mysql:wheel "path/to/mysql/data" after.
#
# Instructions:
#
# 1. Install Xcode (http://developer.apple.com/xcode/).
# 2. Run these Terminal commands to download it to ~/Sources/ & run it.
# pushd ~/Sources/; curl https://gist.github.com/raw/419201/git-install.bash > git-install.bash; bash git-install.bash; popd
# Or, download & run this file from the dir in which you store source files.
# - For 32-bit install, just open git-install.bash and change the occurrences
# of `-arch x86_64` to `-arch i386`.
# TODO:
# Use `arch` command to detect. If not x86_64, warn and allow user to
# choose via STDIN. If you're reading this right now, that means you're It!
# Implement & email me update, and you'll fall in love 3 months later! :)
# - Open Terminal to that directory and run: bash git-install.sh
#
# References:
# http://www.gnu.org/software/make/manual/make.html
# http://www.gnu.org/software/autoconf/manual/make/Standard-Targets.html
# http://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Reference/ManPages/man1/gcc.1.html
# man make
# man strip
# Git source files:
# - Makefile : http://git.kernel.org/?p=git/git.git;a=blob_plain;f=Makefile;hb=HEAD
# - INSTALL : http://git.kernel.org/?p=git/git.git;a=blob_plain;f=INSTALL;hb=HEAD
###############################################################################
### Download the Latest Stable Version of Git #################################
###############################################################################
echo "Scraping Git's latest stable release version number off the home page"
LSR_NUM=$(curl -silent http://git-scm.com/ | sed -n '/id="ver"/ s/.*v\([0-9].*\)<.*/\1/p')
echo "Downloading & unpacking Git's latest stable release: git-$LSR_NUM"
curl http://kernel.org/pub/software/scm/git/git-$LSR_NUM.tar.gz | tar -xz
pushd git-$LSR_NUM
###############################################################################
### Compile & Install Git #####################################################
###############################################################################
CFLAGS="-isysroot /Developer/SDKs/MacOSX10.6.sdk"
LDFLAGS="-isysroot /Developer/SDKs/MacOSX10.6.sdk"
PREFIX="/usr/local"
export NO_FINK=1
export NO_DARWIN_PORTS=1
echo "Taking ownership of $PREFIX (as homebrew advises) so you don't have to sudo"
# http://userprimary.net/posts/2010/08/19/installing-homebrew-for-OSX/
sudo mkdir -p "$PREFIX"
sudo chown -R "$USER:staff" "$PREFIX"
sudo chown -R _mysql:wheel "$PREFIX/mysql/data" # if mysql data dir exists
echo "Compiling & Installing Git to $PREFIX"
# Compile (make all)
make CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" prefix="$PREFIX" all
# Strip (make strip)
make CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" prefix="$PREFIX" strip
# Install (make install)
mkdir -p "$PREFIX/share/man"
make CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" prefix="$PREFIX" install
###############################################################################
### Install Git Tab-Completion for Terminal Usage #############################
###############################################################################
echo "Copying Git's Bash completion script to $HOME/.git-completion.bash"
cp contrib/completion/git-completion.bash "$HOME/.git-completion.bash"
if [[ ! -s "$HOME/.bash_profile" && -s "$HOME/.profile" ]] ; then
profile_file="$HOME/.profile"
else
profile_file="$HOME/.bash_profile"
fi
if ! grep -q 'git-completion.bash' "${profile_file}" ; then
echo "Editing ${profile_file} to load ~/.git-completion.bash on Terminal launch"
echo >> "${profile_file}"
echo "source ~/.git-completion.bash" >> "${profile_file}"
fi
###############################################################################
### Install Manpages ##########################################################
###############################################################################
echo "Downloading & unpacking Git Manpages to $PREFIX/share/man/"
curl http://www.kernel.org/pub/software/scm/git/git-manpages-$LSR_NUM.tar.gz |
tar -xzC "$PREFIX/share/man/"
###############################################################################
### Clean Up: If you move something, put it back. #############################
###############################################################################
# Note: We leave the source files, but you may delete them because they're only
# needed to install Git.
unset LSR_NUM
unset CFLAGS
unset LDFLAGS
unset PREFIX
unset NO_FINK
unset NO_DARWIN_PORTS
popd
echo "Set your name & email to be added to your commits."
echo -n "Please enter your name: "
read git_name
echo -n "Please enter your email: "
read git_email
git config --global user.name "$git_name"
git config --global user.email "$git_email"
unset git_name
unset git_email
git config --global core.excludesfile ~/.gitignore
git config --global rerere.enabled 1
git config --global branch.master.remote origin
git config --global branch.master.merge refs/heads/master
git config --global alias.br branch
git config --global alias.ci "commit -a"
git config --global alias.co checkout
git config --global alias.df diff
git config --global alias.lg log
git config --global alias.ll "log -p"
git config --global alias.rb rebase
git config --global alias.fix "rebase -i origin/master"
git config --global alias.rbc "rebase --continue"
git config --global alias.re remote
git config --global alias.st status
git config --global alias.up "pull --rebase"
@Longobard
Copy link

Quite a few years later, it doesn't seem to work on my side (mac mini 2006, Snow Leopard).
It is more than likely that it is my fault being a total dumb on the Terminal side

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