A repository holding dot and conf files
git init --bare $HOME/.dotfiles
alias config='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
config config --local status.showUntrackedFiles no
echo "alias config='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.zshenv
- The first line creates a folder
~/.dotfiles
is a Git bare repository that will track the configuration files. - Next lines create an alias
config
which will be used instead of the regulargit
to interact with the configuration repository. - Set a flag
-local
to the repository to hide files that are not being explicitly tracked. This is soconfig status
and other commands can be used later, files that should not be tracked will not show up as untracked. - Also you can add the alias definition by hand or use the the fourth line provided for convenience.
The above lines are packaged nto a snippet in gist and linked from git.io
. So things can be set up with:
curl -Lks https://git.io/JT4bp | /bin/zsh
After the setup has been executed any file within the $HOME folder can be versioned with normal commands, replacing git
with the newly created config
alias, like:
config status
config add .vimrc
config commit -m "Add vimrc"
config add .bashrc
config commit -m "Add bashrc"
config push
- Prior to the installation ensure the alias below is in the
.zsh
file:
alias config='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
- Ensure the source repository ignores the folder where it is cloned, so that there aren't recursion problems:
echo ".dotfiles" >> .gitignore
- Clone dotfiles into a bare repository in your
$HOME
:
git clone --bare <git-repo-url> $HOME/.dotfiles
- Checkout the actual content from the bare repository to
$HOME
:
config checkout
- Set the flag
showUntrackedFiles
to no on this specific (local) repository:
config config --local status.showUntrackedFiles no
Taken from Nicola Paolucci article.