Tracking Dotfiles with Git

Table Of Contents ↓


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:

How to distribute dotfiles

git clone --bare ~/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.


$ git --version
git version 1.7.3


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