LinuxCommandLibrary

dotbare

Manage dotfiles using Git

SYNOPSIS

dotbare [-g DIR | --git-dir DIR] [-w DIR | --work-tree DIR] [-h | --help] [-V | --version] <SUBCOMMAND> [<ARGS>]

Subcommands: add [-f] <path>...
rm [-r | -f] <path>...
ls [-a] [-l] [<path>...]

PARAMETERS

-g, --git-dir <DIR>
    Sets path to bare Git repository (default: $XDG_CONFIG_HOME/dotfiles)

-w, --work-tree <DIR>
    Sets path to work tree (default: $HOME)

-h, --help
    Prints help information

-V, --version
    Prints version information

-f (add/rm)
    Force add/remove, overwrites existing files

-r (rm)
    Recursively remove directories

-a (ls)
    List all files, including outside tracked set

-l (ls)
    Use long listing format

DESCRIPTION

Dotbare simplifies dotfiles management by leveraging a bare Git repository, avoiding common pitfalls like symlinks conflicting with Git's index. It works by setting up the bare repo (default: ~/.dotbare) and a worktree matching the user's home directory. Files are checked out on-demand via shell hooks.

Key workflow: Initialize with git init --bare $XDG_CONFIG_HOME/dotfiles, alias dotbare to git --git-dir=$XDG_CONFIG_HOME/dotfiles --work-tree=$HOME, then use dotbare commands to add/rm/ls files. Shell integration exports DOTBARE_{GIT_DIR,WORK_TREE} and sets aliases (dotbare-add, etc.). This enables git status, git add, git commit directly on dotfiles without manual path prefixes.

Ideal for users tired of complex symlinking scripts, providing a seamless Git experience for config files across machines.

CAVEATS

Requires Git 2.23+ for worktree support; shell integration mandatory (source dotbare.sh or eval bash/zsh export); does not handle conflicts automatically; worktree must not pre-exist.

SHELL INTEGRATION

Source ~/.local/share/dotbare/dotbare.sh or run eval "$(dotbare bash)" in .bashrc. Sets aliases: dotbare-add, dotbare-rm, dotbare-ls; exports Git env vars.

INSTALLATION

Via Cargo: cargo install dotbare; or Arch AUR/Nix. Place dotbare.{bash,zsh} in shell profile.

HISTORY

Created by Lucas Albrecht in 2020 as a Rust CLI tool. Inspired by bare repo dotfiles technique popularized in 2016 blog post. Actively maintained on GitHub with v0.2+ adding shell completions.

SEE ALSO

git(1)

Copied to clipboard