Skip to content
nyckswPublic

About

Git for dotfiles, no fluff

Topics

Resources

Stars

22 stars

Watchers

1 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

Dots

Manage dotfiles using a bare Git repository in $HOME/.dots with $HOME as the work tree. No symlinks, wrappers, or extra dependencies. Just Git.

Here's the basic idea, it's very simple:

alias dots='git --git-dir=$HOME/.dots --work-tree=$HOME'
dots init
dots config --local status.showUntrackedFiles no
dots add .bashrc  # Then dots commit, push, pull, etc.

Use dots-install.sh to do the same kind of setup but with a comprehensive gitignore file and a pre-commit hook to make sure you don't do anything dumb, like check in your private keys or accidentally commit your entire homedir.

Installation

This assumes you already have a dotfiles repository URL to pass as an argument.

Warning: This overwrites local files with your remote repository contents.

Review dots-install.sh (it's very short) and then use it like this:

curl -fsSL "https://raw.githubusercontent.com/nycksw/dots/main/dots-install.sh" \
  | bash -s -- -r git@github.com:YOUR_USERNAME/YOUR_REPO.git -c -h -g

You'll need an alias in your .bashrc (or .zshrc, etc.), something like this:

alias dots='git --git-dir=$HOME/.dots --work-tree=$HOME'

Then just use it like you would Git, but from any directory:

dots status
dots add ~/.bashrc
dots commit -m 'Update bashrc'
dots push

Installation Options

Automated Setup

./dots-install.sh -r <YOUR_REPO> -c -h -g

Interactive Setup

./dots-install.sh

The installer can:

  • Clone your remote dotfiles repository
  • Install a pre-commit hook to prevent large commits
  • Download a comprehensive .gitignore_dots file

Advanced Usage

System-Specific Configs

I keep it simple and just source different configs per machine/domain/lsb-release/whatever in .bashrc, something like this:

for FILE in \
  "${HOME}/.bashrc_$(dnsdomainname -s)" \
  "${HOME}/.bashrc_$(hostname -s)"; do
  [[ -f "${FILE}" ]] && source "${FILE}"
done

That way you can put your generic shell config in .bashrc and separate your environment-specific tweaks into files that only get sourced under the correct circumstances.

Or, you can keep customized branches and rebase/merge them onto/into main when needed. It's just Git with your own personal reposistory, so you can push --force-with-lease and live on the edge if you want. Or, whatever, use it however you like to use Git.

Helper Functions

See helpers.sh for random stuff like:

  • dots-deploy - Push dotfiles to remote hosts
  • dots-export - Create tarball archives
  • dots-yoink - Pull changes from remote hosts

Example Output

See example.md for installation walkthrough.

Why Not Stow/dotbot/chezmoi?

Those tools add dependencies and complexity. This approach uses only Git. It's simpler, more portable, and you already know how to use it. If you are familiar with Git it all feels very natural and the safeguards make it pretty hard to screw things up.

Security

Always review scripts before running them. Consider forking/cloning this repository and using your own copy.

Credits

Inspired by this very old HN suggestion for bare Git repository dotfile management.

About

Git for dotfiles, no fluff

Topics

Resources

Stars

22 stars

Watchers

1 watching

Forks

Contributors

Languages