How to manage dotfiles with a Git bare repository

I am using this solution since 2~ years and works on my workstation and laptop with no issues.

You can find a lot of articles about it so I will be fast.

First of all a Git bare repo is different from the classic Git repository.

The idea is that you don’t have a git repo in a specific folder with a detection of the file updated that you can commit but a whole folder with some files that you want to commit. Ifyou want a more complete definition check the link above.

Anyway this basically is perfect for dotfiles, as I have the folder on /home/mte90/ that is a git bare repo committed to a repo.

So the first step after creating a git bare repo in that folder git init --bare is time to add and commit those files.

alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles.git/ --work-tree=$HOME"

This bash alias is for you, this let you to specify the settings that as git bare repo cannot find when you are inside that folder.

Now you are ready to use dotfiles as git alias just for add, commit and so on your dotfiles repository.

How to use it? Well this is based on your needs but you can take inspiration from mine repository at GitHub.

Includes my neovim configs, vlc, bash stuff, git and few other things.

I have to say that saved my time a lot of time when I was working on updates or changing things and with the commit history I was able to revert or change some stuff.

Liked it? Take a second to support Mte90 on Patreon!

Leave a Reply

Your email address will not be published. Required fields are marked *

How to manage dotfiles with a Git bare repository

time to read: 1 min
0