This is a git repo meant to store my various personal config files. Following documentation is mostly for me when I forget how to do this by the time I buy a new computer. If you are not future me, make sure you replace the git repo urls with your own.
Idea mostly stolen from:
- StreakyCobra's comment on a Hacker News thread
- durdn's article
git init --bare $HOME/.cfg
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
config config --local status.showUntrackedFiles no
echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> $HOME/.zshrc
- Note that the
echo
command writes to~/.zshrc
. If you are not using zsh, this will be different.
At this point, we have initialised a bare git repo and setup up the config
alias.
We can now use it to version any file in our $HOME
folder:
config status
config add .zshrc
config commit -m "Added .zshrc"
config push
- create a new empty repo on github (no
README.md
) - run:
config remote add origin https://github.com/dchae/.cfg.git
git clone --bare https://github.com/dchae/.cfg.git $HOME/.cfg
# restart shell
config checkout
# delete conflicting files if they exist
config config --local status.showUntrackedFiles no
- This assumes you are still running zsh and the aliased .zshrc is working. If not, do the alias echo from step 1 again.