I originally set out with the simple approach of Managing my dotfiles as a git repository. This concept was stupid simple. Make $HOME
a git repo, add *
to the .gitignore
so your git status
is clean (no untracked files). Then git add -f
files you wish to track. No aliases, no bare repo nonsense, just a simple git repo. This worked - very well.
The ONLY issue was that my entire $HOME
directory was a git repo. A git status
always had something to report. The git information displayed in the shell prompt always indicated I was on master with no changes. Occasionally I might get confused, wait, is this really a git repo or is this my dotfiles repo... I better git remote -v
to see what repo I'm actually in.
Eventually this small issue festered and I started looking closer at the bare repo solutions. On the surface, they seemed more complicated, which is why I avoided them originally. eventually, two things became evident:
- The initial clone is a bare clone, but we don't work on that bare repo. Immediately after the clone, we checkout a work tree.
- We instruct git to checkout the work tree to a location outside the repo directory!. This is why the alias comes in - to associate the work tree with the git repo.
So, not so complicated afterall.
- curl
- git
On a new system run this command:
curl -Lks https://raw.githubusercontent.com/erniedotson/dotfiles/master/.bin/install.sh | /bin/bash
This will attempt to:
- clone the repo into
~/.dotfiles
- checkout the files to
$HOME
- If existing dotfiles are found, they will be copied to
~/.dotfiles-backup/
- If existing dotfiles are found, they will be copied to
- update
~/.bashrc
and~.zshrc
files withdfgit
alias.
Log out and back in for your new dotfiles to be loaded.
The git
command will not work in your $HOME
directory because it is not a git repo. An alias saves the day:
alias dfgit='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
Instead use the alias, dfgit
, along with any git commands. For example, git status
becomes dfgit status
.
What is the best git config set up when you are using Linux and Windows?
git config --system core.autocrlf false