My dotfiles, tracked in a bare git repository. No fuss, no special sauce.
Technique borrowed from Nicola Paolucci's blog post and Derrick Reimer.
The configuration files assume you have Zsh installed and robbyrussell/oh-my-zsh.
At the time of writing, Homebrew is a great way to install Zsh.
brew install zsh zsh-completions
chsh -s /bin/zshThis repository contains a .zshrc file, which you will want to override the
default file created by Zsh. If you need to retain your existing .zshrc file,
move it to a different spot:
cd ~
mv .zshrc .zshrc.pre-dotfilesNext, ensure that your .dotfiles directory will be ignored by Git (to eliminate
recursion issues) by adding to .gitignore:
touch .gitignore
echo ".dotfiles" >> .gitignoreThen, clone this repository into your home directory:
git clone --bare https://github.com/jwbaldwin/dotfiles.git $HOME/.dotfilesCheckout the content of the repository into $HOME:
git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME checkoutIf there are conflicts with existing files, Git will let you know like this:
error: The following untracked working tree files would be overwritten by checkout:
.gitconfig
Please move or remove them before you can switch branches.
Aborting
Be sure to back those up first before moving forward.
Restart your shell session to pick up all the new aliases and configurations.
You'll want to tell Git to ignore untracked files when running git status,
since this repository will only manage certain hand-picked files in your
home directory:
dotfiles config --local status.showUntrackedFiles noSuppose you just made a change to your .zshrc file and would like to commit it
to your dotfiles repo.
# See your proposed changes
dotfiles status
# Stage up your changes
dotfiles add .zshrc
# Commit it
dotfiles commit -m "Message goes here"
# Push it up
dotfiles pushYou'll want to avoid running an "add all" command (like dotfiles add . or dotfiles add -A)
since only some of the files in the home directory are tracked by Git.
Once directory is under git management, run the bootstrap script to perform additional environment setup (tap Homebrew bundle, install Zsh, etc.):
script/bootstrapTo install new Homebrew packages, add to the Brewfile, run brew bundle,
and commit your changes.
To bring your existing home directory under version control, initialize a bare git repository there and define an alias to help with managing it:
git init --bare $HOME/.dotfiles
alias dotfiles='/usr/local/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles noBe sure to add the alias to .zshrc, either manually or like this:
echo "alias dotfiles='/usr/local/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.zshrcNow, you can run ordinary git commands in your home directory using your newly
created dotfiles alias:
dotfiles status
dotfiles add .zshrc
dotfiles commit -m "Add zshrc"
dotfiles push