Skip to content

Instantly share code, notes, and snippets.

@SeppoTakalo
Created December 3, 2024 09:44
Show Gist options
  • Save SeppoTakalo/b8b3f9361f2e906e1855459e86b52429 to your computer and use it in GitHub Desktop.
Save SeppoTakalo/b8b3f9361f2e906e1855459e86b52429 to your computer and use it in GitHub Desktop.
Manage dotfiles with git

Manage dotfiles with git

Manage dotfiles with git using a bare repository and shell alias.

Based on information on various proposals:

Setup

git init --bare $HOME/.dotfiles

Create alias (add to .bashrc or .zshrc)

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

Hide untracked files

dotfiles config --local status.showUntrackedFiles no

Add files

dotfiles add .bashrc
dotfiles commit -m "..."

Pushing

dotfiles remote add origin <URI>
dotfiles push origin main

Cloning on a new computer

git clone --bare <URI> $HOME/.dotfiles
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
dotfiles checkout --force
dotfiles config --local status.showUntrackedFiles no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment