My dotfiles.
Find a file
2025-08-12 21:14:53 +02:00
.config feat(helix): configure markdown 2025-08-12 21:14:53 +02:00
.librewolf feat(librewolf): deactivate rfp 2025-04-02 22:33:09 +02:00
.local refactor(shell): install nushell 2025-08-12 21:10:13 +02:00
.bash_aliases feat(bash): add file for aliases 2025-05-21 10:48:43 +02:00
.gitconfig refactor(git): remove work config 2025-08-12 21:10:15 +02:00
.gitconfig.catppuccin chore(catppuccin): update themes 2025-02-15 17:41:42 +01:00
.gitconfig.personal feat(git): update personal config 2025-05-21 13:45:35 +02:00
.gitignore feat(git): add .cfg folder 2025-05-21 10:57:06 +02:00
.gitmessage feat(git): add config 2024-08-17 23:09:15 +02:00
README.md refactor(shell): install nushell 2025-08-12 21:10:13 +02:00

💾 Dotfiles: Bare git repository

https://www.atlassian.com/git/tutorials/dotfiles


The technique consists in storing a Git bare repository in a "side" folder (like $nu.home-path/.cfg or $nu.home-path/.myconfig) using a specially crafted alias so that commands are run against that repository and not the usual .git local folder, which would interfere with any other Git repositories around.

Starting from scratch

git init --bare $nu.home-path/.cfg
alias dot = git --git-dir=($nu.home-path | path join .cfg) --work-tree=($nu.home-path)
dot config --local status.showUntrackedFiles no
  • The first line creates a folder ~/.cfg which is a Git bare repository that will track our files.
  • Then we create an alias config which we will use instead of the regular git when we want to interact with our configuration repository.
  • We set a flag - local to the repository - to hide files we are not explicitly tracking yet. This is so that when you type config status and other commands later, files you are not interested in tracking will not show up as untracked.

Once you've run the setup, any file in the $HOME folder can be versioned using normal commands, replacing git with your newly created config alias, such as:

dot status
dot add .vimrc
dot commit -m "Add vimrc"
dot add .bashrc
dot commit -m "Add bashrc"
dot push

Installing your dotfiles onto a new system (or migrate to this setup)

If you already store your configuration/dotfiles in a Git repository, on a new system you can migrate to this setup with the following steps:

  • Prior to the installation make sure you have committed the alias to your .bashrc or .zsh:
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
  • And that your source repository ignores the folder where you'll clone it, so that you don't create weird recursion problems:
echo ".cfg" >> .gitignore
  • Now clone your dotfiles into a bare repository in a "dot" folder of your $nu.home-path:
git clone --bare <git-repo-url> $nu.home-path/.cfg
  • Define the alias in the current shell scope:
alias dot = git --git-dir=($nu.home-path | path join .cfg) --work-tree=($nu.home-path)
  • Checkout the actual content from the bare repository to your $HOME:
dot checkout
  • The step above might fail with a message like:
error: The following untracked working tree files would be overwritten by checkout:
    .bashrc
    .gitignore
Please move or remove them before you can switch branches.
Aborting

This is because your $nu.home-path folder might already have some stock configuration files which would be overwritten by Git. The solution is simple: back up the files if you care about them, remove them if you don't care. I provide you with a possible rough shortcut to move all the offending files automatically to a backup folder:

mkdir -p .cfg-backup && \
dot checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | \
xargs -I{} mv {} .cfg-backup/{}
  • Re-run the check out if you had problems:
dot checkout
  • Set the flag showUntrackedFiles to no on this specific (local) repository:
dot config --local status.showUntrackedFiles no
  • You're done, from now on you can now type config commands to add and update your dotfiles:
dot status
dot add .vimrc
dot commit -m "Add vimrc"
dot add .bashrc
dot commit -m "Add bashrc"
dot push