This repository is for my personal dotconfig files.
Note: This repo will only contains system dotfiles as for Emacs and DWM has its own respective repositories.
My dotfiles are managed using git --bare
, No need symlinking. For better understanding on managing dotfiles this way check out Distrotube’s Youtube Video.
- Create alias for easier management
# For bash it'd be .bashrc echo 'alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME"' >> $HOME/.zshrc source ~/.zshrc
- You are ready to clone
echo ".dotfiles" >> .gitignore
git clone --bare https://www.github.com/rezaamashi/repo.git $HOME/.dotfiles
dotfiles checkout
- Hide Untracked files so that you could only see the things that matters
dotfiles config --local status.showUntrackedFiles no
# To manage your files
dotfiles status
# To add a new file
dotfiles add .vimrc
dotfiles commit -m "Add vimrc"
# And push it to your own repo
dotfiles remote add origin https://www.github.com/your-username/your-repo.git
dotfiles push origin master
git init --bare $HOME/.dotfiles
echo 'alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME"' >> $HOME/.zshrc
source ~/.zshrc
dotfiles config --local status.showUntrackedFiles no
If you use magit
for version control management, you would need to set up special function to manage git --bare
repositories. Here is my setup for my dotfiles, add this to your init.el
:
(setq bare_git_dir (concat "--git-dir=" (expand-file-name "~/.dotfiles")))
(setq bare_work_tree (concat "--work-tree=" (expand-file-name "~")))
;; use maggit on git bare repos like dotfiles repos, don't forget to change `bare-git-dir' and `bare-work-tree' to your needs
(defun rz/magit-status-dotfiles-bare ()
"set --git-dir and --work-tree in `magit-git-global-arguments' to `bare-git-dir' and `bare-work-tree' and calls `magit-status'"
(interactive)
(require 'magit-git)
(add-to-list 'magit-git-global-arguments bare_git_dir)
(add-to-list 'magit-git-global-arguments bare_work_tree)
(call-interactively 'magit-status))
;; if you use `rz/magit-status-bare' you cant use `magit-status' on other other repos you have to unset `--git-dir' and `--work-tree'
;; use `rz/magit-status' insted it unsets those before calling `magit-status'
(defun rz/magit-status ()
"removes --git-dir and --work-tree in `magit-git-global-arguments' and calls `magit-status'"
(interactive)
(require 'magit-git)
(setq magit-git-global-arguments (remove bare_git_dir magit-git-global-arguments))
(setq magit-git-global-arguments (remove bare_work_tree magit-git-global-arguments))
(call-interactively 'magit-status))
I bind the function rz/magit-status-dotfiles-bare
to SPC-G
, and rz/magit-status
to SPC-g
. That way I could manage my dotfiles configuration using SPC-G
, and the usual magit-status
using SPC-g
.