iquabius / dotfiles

My dotfiles managed by git using a custom `--work-tree`.
1 stars 0 forks source link

Replace VCSH & Myrepos with bare git #3

Open iquabius opened 2 years ago

iquabius commented 2 years ago

Creating the new repository

A lot of tutorials uses a bare git repository, but that's not strictly necessary. Check .

The secret sauce is the work tree configuration, not the bare repository. I discovered that using a non-bare repository is functionally identical.

Gabrielle Young on The best way to store your dotfiles: A bare Git repository EXPLAINED. August 3, 2020.

git init $HOME/.dotfiles

Add alias to ~/.config/fish/config.fish:

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

Refresh current shell:

source ~/.config/fish/config.fish
dotfiles config --local status.showUntrackedFiles no

Setting up on a new system

I tried this in a fresh install of Garuda Sway edition.

sudo pacman -S keepassxc

sudo pacman -S github-cli
gh auth login
gh repo clone iquabius/dotfiles $HOME/.dotfiles
ERROR: No access

# fish shell
eval (ssh-agent -c)
keepassxc

echo ".dotfiles" >> .gitignore

gh repo clone iquabius/dotfiles $HOME/.dotfiles

alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/.git/ --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles no
dotfiles checkout

fisher update

Refs

iquabius commented 2 years ago

After running dotfiles checkout on a new system I don't get all repo files like the article says:

Git pulls the tracked files out of the compressed database in the Git directory and places them in the work tree.

I forgot to add ".dotfiles" to .gitignore. Could that be the problem?

By running dotfiles status I see that every file is deleted.

So I need to run dotfiles reset --hard to "undelete" the files.

Could that be improved?

iquabius commented 2 years ago

On Archcraft I used exec ssh-agent zsh to start SSH agent.

For bash it could be eval $(ssh-agent -s).

Refs:

iquabius commented 1 year ago

To make it work with Magit on Emacs:

echo 'gitdir: ./.dotfiles/.git/' >> ~/.git
dotfiles config --local core.worktree ../../

https://stackoverflow.com/questions/34169458/emacs-magit-git-dir-is-not-in-the-default-place