Skip to content

Instantly share code, notes, and snippets.

@Alec1017
Created April 3, 2024 21:00
Show Gist options
  • Save Alec1017/ee55b4ce4420d5a69249a7dc71303c59 to your computer and use it in GitHub Desktop.
Save Alec1017/ee55b4ce4420d5a69249a7dc71303c59 to your computer and use it in GitHub Desktop.
Bare github repository for dotfiles

Setting up a bare repository

Create the repository:

git init --bare $HOME/.dotfiles-git

Add an alias that separates interacting with the dotfiles repository:

git config --global alias.dotfiles '!git --git-dir=$HOME/.dotfiles-git/ --work-tree=$HOME'

When running git status, only show files that have previously been tracked:

 git dotfiles config status.showUntrackedFiles no

Using the bare repository

The repository can be used to track dotfiles in the same way as you would normally use git:

git dotfiles add .
git dotfiles commit -m "my commit"
git dotfiles push origin main

Cloning the bare repository

Make sure the alias has already been added:

git config --global alias.dotfiles '!git --git-dir=$HOME/.dotfiles-git/ --work-tree=$HOME'

To clone a bare repository, run:

git clone --bare <git-repo-url> $HOME/.dotfiles-git

Checkout the actual content from the dotfiles repository:

git dotfiles checkout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment