Skip to content

Instantly share code, notes, and snippets.

@kevmoo
Created February 27, 2026 16:27
Show Gist options
  • Select an option

  • Save kevmoo/afe049992bfca570ce8fb34e32c2f412 to your computer and use it in GitHub Desktop.

Select an option

Save kevmoo/afe049992bfca570ce8fb34e32c2f412 to your computer and use it in GitHub Desktop.
kevmoo cli setup crazy

πŸ“‚ Managing Dotfiles with a Bare Git Repository

This setup allows for managing configuration files (dotfiles) directly in the $HOME directory using Git, without the need for symlinks, specialized management tools, or messy directory structures.

πŸš€ The Implementation

The core of the system is a bare Git repository located at ~/.dotfiles/. Unlike a standard repository, a bare repo doesn't have a default working directory. We manually point its "working tree" to $HOME using a simple shell alias.

The Magic Alias

Add this to your .bashrc or .zshrc:

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

βš™οΈ Key Configuration

To prevent Git from showing every untracked file in your home directory (which would make dot status unusable), we configure the repository to ignore untracked files by default:

dot config --local status.showUntrackedFiles no

πŸ’Ž Why This Approach?

  • Zero Symlinks: Files live in their natural locations (e.g., ~/.bashrc, ~/.gitconfig). You don't need to manage a complex tree of symlinks or use tools like GNU Stow.
  • Native Git Experience: Since dot is just a standard Git command with specific flags, all your existing Git knowledge applies (dot status, dot add, dot commit, dot diff, etc.).
  • Portable & Lightweight: This works on any system with Git installed. No Python, Ruby, or Node.js dependencies are required.
  • Clean Workflow: Only files you explicitly dot add are tracked. The rest of your home directory remains invisible to Git.

πŸ›  Common Workflows

Tracking a new config file

dot add ~/.bashrc
dot commit -m "Add bashrc to dotfiles"

Reviewing changes

dot status
dot diff

Syncing with a remote

dot push origin main
dot pull origin main

Initial Setup on a New Machine

  1. Clone the repo as a bare repository:
    git clone --bare <your-repo-url> $HOME/.dotfiles
  2. Define the alias in your current shell session:
    alias dot='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
  3. Checkout the content into your home directory:
    dot checkout
  4. Silence untracked files:
    dot config --local status.showUntrackedFiles no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment