These are my configuration files with settings applicable to all machines I'm
using. Where possible, a file sources another, machine specific file, for
example: .profile
sources .profile_local
. The machine specific dotfiles
live in a private GitHub repo.
This repo is best cloned as a bare repository straight into $HOME
. This
Gist contains a script that clones the repository, configures it to ignore
untracked files and do sparse checkout (so README.md
and LICENSE
don't show
up), and initializes all the submodules. It can be run like this, preferably in
$HOME
:
bash <(curl -L https://git.io/JJczn)
Notice that this overwrites existing dotfiles.
From now on, dotfiles can be manipulated with gdf
, which is an alias for
git --git-dir="$HOME/.dotfiles.git" --work-tree="$HOME"
with the same tab completion as git
itself.
For example, after a change to .bashrc
, you'd use
gdf add .bashrc
gdf commit -m "Update .bashrc"
gdf push
The structure of using two repositories with generally applicable dotfiles in the first sourcing machine specific ones from the second was inspired by this great article by Anish Athalye.
I've seen the idea of using a bare repository for dotfiles first in this comment by StreakyCobra on Hacker News. People then expanded on the idea and wrote about it, specifically Nicola Paolucci in his tutorial (adding the idea of using something like a Gist for initialization and pointing out problems if the files exist already) and Harfang in a blog post.