public
Last active

Bash Script to Install Git on Mac OS X 10.6 (Snow Leopard) Intel x86 (32 bit)

  • Download Gist
.gitconfig
INI
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
[user]
name = Matt Di Pasquale
email = my@fake-email.com
[alias]
br = branch
c = clone --recursive
ci = commit -av
co = checkout
df = diff
lg = log
ll = log -p
rb = rebase
rbc = rebase --continue
re = remote
st = status
up = pull --rebase
[core]
excludesfile = ~/.gitignore
[rerere]
enabled = 1
.gitignore
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# 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/*
git-install.bash
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
#!/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 -arch x86_64"
LDFLAGS="-isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64"
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
gitconfig.bash
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
# Install these useful Git aliases & configurations with the following command:
# $ bash <(curl -s https://gist.githubusercontent.com/mattdipasquale/419201/raw/gitconfig.bash)
 
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 alias.br branch
git config --global alias.cr "clone --recursive"
git config --global alias.ci "commit -av"
git config --global alias.co checkout
git config --global alias.df diff
git config --global alias.dwc "diff -w -M --color-words"
git config --global alias.lg log
git config --global alias.ll "log -p"
git config --global alias.rb rebase
git config --global alias.rba "rebase --abort"
git config --global alias.rbc "rebase --continue"
git config --global alias.rbi "rebase --interactive"
git config --global alias.re remote
git config --global alias.st status
git config --global alias.sup "submodule foreach 'git co master; git up'"
git config --global alias.tree "log --graph --decorate --pretty=oneline --abbrev-commit --all"
 
git config --global color.ui auto
git config --global color.interactive auto
 
git config --global rerere.enabled 1

useful!

an alert: to work in 32 bits version it's necessary remove "-arch x86_64" in lines 63 and 64 from git-install.bash file.

Do not use git-install.bash to install Git. Use homebrew instead. Homebrew also has an option you can set to install the 32-bit version.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.