This repository manages jadler’s dotfiles.
I recently looked for a way to manage my dotfiles. I discovered stow, but at the same time I discovered this video (Git Bare Repository - A Better Way to Manager dotfiles) on youtube and thought this was a more interesting and elegant solution that I decided to try myself.
Since it is not possible to clone a repository into a nonempty directory, the process will be the same for those starting out with a new repository or for those who already have a populated one.
NOTE: This operation will overwrite any file with the same name you have in your working directory.
Update the script with information pertinent to your repository and the git directory location and be sure to give the script execute permissions.
_GITDIR=${HOME}/.dotfiles
_WORKTREE=${HOME}
_REPOSITORY=git@github.com:jadler/dotfiles.git # your github dotfile repository
git init --separate-git-dir=${_GITDIR} ${_WORKTREE}
rm ${_W
53BE
ORKTREE}/.git
alias dotfiles='git --git-dir=${_GITDIR} --work-tree=${_WORKTREE}'
dotfiles config --local status.showUntrackedFiles no
dotfiles remote add origin ${_REPOSITORY}
dotfiles fetch
if dotfiles show-ref -q --heads master; then
dotfiles checkout -t origin/master -f
fi
After running the script, add the alias created in the script to make future operations easier.
alias dotfile='git --git-dir=${HOME}/.dotfiles --work-tree=${HOME}'
For those who are facing the problem: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
run the following command:
dotfile commit --allow-empty -n -m "First commit"