How i alias git to manage my home directory (for dotfiles)

I am writing this on the first Saturday of September 2022 but the solution described is in use since exactly two years ago already.

I have a repository, hosted on GitHub, it's public and it's mkf/homedirconfig.

They way I set it up:

alias gd        env GIT_WORK_TREE="$HOME" \
                    GIT_DIR="$HOME/.gd" \
                    GIT_CONFIG="$HOME/.gdconfig" \
                git -c "core.excludesfile=$HOME/.gdignore"

I also used to achieve identity between branches and then have the branches have some common root, but not doing that anymore.

# Benefits

the .git directory is instead named .gd

the repository's .gitconfig is instead stored as .gdconfig

instead of .gitignore i have .gdignore (funny TIL Godot the game engine has its ignore file named the same haha)

Previously

I used to instead try staging the file .gd/info/exclude (counterpartly, .git/info/exclude)

That wasn't too neat to manage.

It's benefit: it could both be managed by git in a non-aliased repo, as well as being immediately present there and not needing a core.excludesfile setting.

Post scriptum

Whoosh, I just reminded myself of my old blog, and there is a mention of this repo from January 2020. So that's over 2.5y ago.

"Today I asked on Super User: Are .gitignore files from directories above the repository's or from home directory loaded in any versions of Git?" (250 words)

I guess I just didn't host it on Github back then, but on a regular ssh *nix.

This post was prompted by

reading @aelspire's

2022-07-28 – The slacker’s guide to managing dotfiles