How to manage your [dot] files with git. First of all what is dotfiles ? For those who don’t konw dotfiles is configuration files inside your home directory file names and directories starts with a “.” thats why it’s called dotfiles.
The problem ?
- I want to manage it with a git repositry
- I don’t want to mess with all files inside home directory as untracked git files
it was simple and plain in terms of linux way
Choose directory where your repository will be stored for instance ~/Dotfiles
Got inside and make git bare repostory
git init --bare .
Bare repository is repository without a working directory so it’s contains of git internals structure itself to store objects added to repostory
You better know what is bare git repository here
Setup special alias for git command to work with ~/Dotfiles
alias dotfiles='/usr/bin/git --git-dir=$HOME/Projects/Personal/Dotfiles/ --work-tree=$HOME'
Make this alias permanent by adding it to your .bashrc or .zshrc configuraton
Make git stop showing untracked files
dotfiles config status.showUntrackedFiles no
Step 5 Finally
dotfiles add ~/.zshrc
dotfiles -m "Add zsh configuraton"
That’s it. If you want to push to remote add origin before and push it same way
dotfiles add origin URL
dotfiles push origin master
Since dotfiles is special alias for git you can do
dotfiles status when editing your configs to see what files have been changed.