sameem.dev

Updated 3 min read

Managing Dotfiles with a Bare Git Repository

  • #guide
  • #linux
  • #git
  • #dotfiles
DOTFILES title above a file tree of .bashrc, .dir_colors, .config, .firefox and .sddm, with .config expanded to hyprland, waybar, rofi, dunst, swaylock, fastfetch, alacritty, neovim and zathura

Update (September 2026): I’ve moved on from Hyprland. As a web developer I live in the browser, and keeping the browser window rules behaving the way I wanted meant revisiting my config after most Hyprland updates. I wanted a setup that just works, so I switched to GNOME and then to KDE Plasma. I’ve found my home in Plasma and plan to stay for a long time. The bare Git repository approach below still works the same no matter which desktop you use.

My dotfiles are available in my dotfiles repository on GitHub (opens in a new tab).

What is a dotfile?

Dotfiles, those files starting with a dot in their names, hold the secret to personalizing and refining your system. These configuration files, like .bashrc or .vimrc, represent the identity of your customized computing environment.

Dotfiles empower users to customize their tools and applications according to their preferences. Whether it’s adjusting the appearance of the command prompt, enhancing the capabilities of a text editor, or tuning version control settings, dotfiles provide a platform for modifications.

Sharing dotfiles has become a tradition among tech enthusiasts—an opportunity to exhibit configurations, shortcuts, and optimizations that boost productivity. By copying dotfiles, users can replicate a crafted setup on any machine, ensuring a consistent computing experience throughout.

How to manage dotfiles?

I was looking for a way to manage my dotfiles and read about the bare Git repository technique in Atlassian’s dotfiles tutorial (opens in a new tab). I find it very convenient. To manage your dotfiles with a bare Git repository, follow these steps:

  1. Create a bare Git repository at ~/.dotfiles to track configuration changes.

    git init --bare $HOME/.dotfiles
  2. Set up an alias named config to use instead of the standard git command when working with your dotfiles.

    alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
  3. Tell the repository to hide untracked files, so config status and similar commands only show the files you track.

    config config --local status.showUntrackedFiles no
  4. Optionally, add the alias to your .bashrc so the config command is always available.

    echo "alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.bashrc
  5. Now you can version any file in your $HOME folder with the usual commands. Just use config where you would normally type git:

    config status
    config add .vimrc
    config commit -m "Add vimrc"
    config add .bashrc
    config commit -m "Add bashrc"
  6. Add a remote named origin to your bare repository.

    config remote add origin <remote_repository_url>
  7. Verify the remote has been added successfully.

    config remote -v
  8. Push the changes to the remote repository (e.g., GitHub). If your branch is called main, use that instead of master.

    config push -u origin master
  9. You can also create different branches and check them out when you want to change the theme. There’s a preview video in the dotfiles repository (opens in a new tab).

    config branch
    config checkout mocha
    config checkout dark

Mocha config

These configuration files are in the mocha branch (opens in a new tab).

Hyprland desktop in the Catppuccin Mocha theme, with a terminal showing fastfetch output for Arch Linux, a status bar along the top and a brightness pop-up Nemo file manager and Firefox side by side in the Mocha theme, with an app launcher open over them Mocha lock screen with a round clock showing the time and date over a blurred wallpaper Login screen with the time, a username and password form, and a black car with blue headlights

Dark config

These configuration files are in the dark branch (opens in a new tab).

Hyprland desktop in the dark theme, with a terminal showing neofetch output for Arch Linux over a night-sky wallpaper, a status bar along the top and a volume pop-up Firefox and an empty terminal side by side in the dark theme, with an app launcher searching for racing car Dark lock screen with a round clock showing the time and date over a blurred sunset wallpaper Login screen with the time, a username and password form, and a black car with blue headlights

Written by , a full-stack web developer and team lead at Total-X Softwares.

More posts

All posts