The easiest way to version control your dotfiles.
- Initialize empty repo at home
git init --bare $HOME/.dotfiles
2. Use working directory of git as $HOME
, and git dir as .dotfiles
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
- Only for current local repo, because it's annoying.
config config status.showUntrackedFiles no
- Here you go, check status, add your configs, and commit.
config status
config add .config/mpv
config commit -m "Added mpv config"
- Create repo at github/gitlab and add origin -> Push.
config remote add origin <link>
config push origin master
Here you can use different branches for different computers, you can replicate you configuration easily on new installation -
For using dotfiles on other device
- Clone repo into home, if its empty
git clone --separate-git-dir=~/.myconf <link-to-repo> ~
- Or clone into separate tmp dir, otherwise it will fail if your home directory isn't empty. Then copy your configs and remove tmp dir.
git clone --separate-git-dir=$HOME/.dotfiles <link-to-repo> $HOME/dotfiles-tmp
cp ~/dotfiles-tmp/.vimrc ~
rm -r ~/myconf-tmp/
- Again set alias to manage dotfiles.
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
Done! easy peezy lemon squeezy :)
Reference: ArchWiki | Ycombinator