Most applications I use daily are running on my workstation and all
dotfiles are written, edited and kept there. From the workstation they
are distributed to other machines. What usually happens is that I do
massive syncing and then neglect remote systems, sometimes even for
months. I'm always trying to improve my environment so often I would
end up with completely different working environments. I needed a
better solution and git seemed
perfect for the job. I guess other distributed version control
systems would be just as good but I was already familiar with git. I
won't cover the actual git commands, by this
point tutorials are just about
everywhere, I will rather explain my work-flow.
There are many approaches, most popular seem to be; keeping your
dotfiles in a repo and symlinking them back to $HOME or
keeping your whole $HOME in git and ignoring mostly
everything. Some people also use a bit of trickery to change the git
work tree while keeping the repo in another directory and some employ
specific tools
like git-home.
After reviewing all the popular solutions I decided to go with another
approach. I created a repo in the "~/dotfiles.git" directory
and copied all important dotfiles there. I then use a script
called gitup
that for each file (or directory) in the current directory checks if
there is a dotfile with the same name in $HOME. If the file
exists and it changed the script copies it over. An acquaintance uses
this approach to easily share his dotfiles
via github. It seemed cleaner than symlinks to me, but
it does require more work.
I do all modifications on the actual files and later
use gitup to get the repo up to date. After I commit they can
be distributed further. When I'm setting up a new machine, or an
account, I clone the workstation repo directly. Afterwords I
can push from the workstation or pull from remote
machines when a change happens. Workstation has only the master
branch but each remote machine is different and some need to have
specific local changes. When that happens I create a new
local branch and do my changes there. Most of the time I
"live" in the local branch, when something eventually changes
in master I rebase it. Whole setup requires some
work and it's not perfect, but it certainly beats everything else I
tried.