Dotfiles git command

How Create Dotfiles Repository using Git Bare

As Linux user and Destro tester, all configuration files which we use for applications, for example, vim configuration which store in Linux Home directory folder, when we switch Distro or want to recollect last changes in our config file its very hard to remember.

Sometimes any changes in config files may lead to application unstable so most of the people save their config files in dotfile and sync with Git.

I use Gitlab to sync my dotfile, so whenever I switch distros for example currently I am using Fedora Gnome switched from Ubuntu i3.

now doing all my Application settings no need to bother as the required dotfiles setting is saved on GitLab all I just need to Pull and the settings will take place.

Previously managing dotfile repository I need to move the file in created Git dotfile folder then create Symlink to the particular home folder file location which sometimes hard to manage for example moving a file from Home> config >i3 folder > created script folder and again create a symlink.

Or Some people make a home folder to the git repository and manage unwanted files to .gitignore

This is how i manage my dotfiles using Git bare config. simple solution

Open Terminal Create Folder in Home Directory name dotfiles

$ mkdir $HOME/dotfiles

Initilize Git Bare repository using following command.

$ git init --bare $HOME/dotfiles
Git Bare command in Terminal

Now to Use Git add files in git repository the simple way to create alias that will simplify the task. i use zsh shell so to add allias all i need to add followin line in my .zshrc file same can be add in bashrc file incase simple bash shell is used.

alias dotfile='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME' 


$ echo "alias dotfile='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME'" >> ~/.bashrc
adding dotfile command in zsh

And last command which not show untracked files we can manually add each files. before that we need to close and reopen terminal.

$ dotfile config --local status.showUntrackedFiles no

The Hard Configration part is completed now so from now onwards we need to add files in dotfile git repository its simple command. For example adding neovim init file which is located in .config nvim folder in repository using simple command

$ dotfile add /path/of/file

Commit added files command will be

$ dotfile commit -m "My Commit"

Checking Status and pushing to remote master command.

$ dotfile status
$ dotfile push
Dotfiles git command

You Can check my Dotfiles repository on my GitLab