So, first thing first, I am not trying to backup home in general.
Under Linux or macos, I only want to track some of the ~/.xxx config files, without interfering with, or caring about, lower level repositories, files or directories.
First things first, create the repo:
cd ~
git init
In the past, I did that and ended up with a very "noisy" git repo that was always either complaining about untracked files or about lower level repos that it was not tracking. Yes, submodules can probably help, but they seem overkill here.
So, second thing is to tell it to ignore everything! via .gitignore:
~/.gitignore
.*/*
*
At this point, it is not tracking anything and git status will show nothing going on. It will even actively refuse to add files for tracking (git add foo<tab> will not autocomplete for example).
Now, you can add selectively add only the configuration files you want to backup.
git add -f ~/.wezterm.lua
where -f is the force flag to tell to ignore your .gitignore
And if you want to know what is being tracked in git (since it will silently ignore everything):
git ls-tree -r $(git branch --show-current) --name-only
giving:
.bashrc
.config/Code/User/settings.json
.config/Code/User/snippets/dot.json
.config/Code/User/snippets/html.json
.config/Code/User/snippets/markdown.json
.config/Code/User/snippets/python.json
.config/Code/User/snippets/shellscript.json
.config/dconf/user
.config/mimeapps.list
.gitconfig
.inputrc
.profile
.wezterm.lua
.zshrc