tracking Dotfiles with Git


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 git:// ~/dotfiles.git
#setup bash alias
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