I have setup git under my home assistant directory. The suggest the following configuration:
# Example .gitignore file for your config dir.
# An * ensures that everything will be ignored.
*
# You can whitelist files/folders with !, these will not be ignored.
!*.yaml
!.gitignore
!*.md
Then I added a couple of whitelist AFTER the git was initialize and several commits were made:
# Example .gitignore file for your config dir.
# An * ensures that everything will be ignored.
*
# You can whitelist files/folders with !, these will not be ignored.
!*.yaml
!.gitignore
!*.md
!packages/
!esphome
!syslog-ng/
!python_scripts/**
# Ignore folders.
.storage
So the problem is that files under certain directories are still ignored, despite I clearly stated they should not. For example, under python_scripts folder all .py files are being ignored. Funny .yaml files are not ignored.
I know there are several questions like this, and several answers, but I think my case is different. I think the fact that I whitelisted certain extensions makes git thing that only files with that extension should be unignored.
I can't add !*.py to the gitignore because I only want python files under the pythons_scripts folder to be not ignored.
I already tried several variations like !python_scripts/**/*.py without luck. And also my real objective is to whitelist the entire folder, all contents.
I even tried to add a .gitignore file to that subfolder with the content !*, no luck, git keeps saying:
ā config git:(lovelace.yaml) ā git add python_scripts/*
The following paths are ignored by one of your .gitignore files:
python_scripts
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
Some extra debugging information. Git version
git --version
git version 2.32.0
As you can see, if I add a test.py file git says it ignores it because the * on the main gitignore, despite the clear !* on the nested gitignore.
touch python_scripts/test.py
git check-ignore -v python_scripts/test.py
.gitignore:3:* python_scripts/test.py
python_scripts/.gitignore
!*#
However, yaml files that are whitelisted at root are not ignored:
ls python_scripts
insultar_invitados.py services.yaml test.py
git check-ignore -vv python_scripts/services.yaml
# no output
OS info:
uname -a
Linux a0d7b954-ssh 5.10.70 #1 SMP Mon Oct 4 23:24:22 UTC 2021 x86_64 Linux
cat /etc/alpine-release
3.14.1