Tracking Dotfiles with Git

Table Of Contents ↓

Why?

How to track dotfiles

git init --bare ~/dotfiles.git
alias .G="git --work-tree=$HOME/ --git-dir=$HOME/dotfiles.git"
.G add ~/.gitcofig
.G status -s -uno # review chagelist
.G commit -a -m 'Git: adding user config'

You may want to keep .G alias

alias .G >> ~/.bashrc

Now we need to specify ignores and track .gitignore file.

  1. rename ~/.gitignore to ~/.gitignore-global and specify it in ~/.gitconfig so it can be used as repository ignores file not a user’s one.
  2. ignore everything by default and track only required stuff:
# ignore all by default
/*

# do not ignore:
!bin/
!.bash/
!.vim/
!.ruby/

How to distribute dotfiles

git clone --bare https://github.com/gmarik/dotfiles.git ~/dotfiles.git
#setup bash alias so it can be invoked from anywhere, whenever dotfiles changes are needed
alias .G="git --git-dir=$HOME/dotfiles.git --work-tree=$HOME/"

# commit original files in orig branch for backup
# WARNING: backup what's going to be overwritten
.G status -s -uno 	# review changelist
.G checkout -b original_files
.G commit -a  -m 'original files'
.G checkout master ~/

At this point we should have all dotfiles in place.

PS

$ git --version
git version 1.7.3

TODO

Read More
Installing ruby 1.8.6 on OSX
Blogging with Jekyll, Rack and Heroku for free!
Comments
read or add one↓