Is it possible to add to .gitignore rules depends on environment variables?
for example
if -e $(ENV_VAR) \"AAA\"
!liba.so
else
liba.so
The answer is no.
Gitignore rules are completely static. Further that would not even make any sense. Once a file is in the repo, gitignore does not apply to it anymore – it only prevents new files from being added.
That being said, you can have a local “gitignore”: anything in .git/info/exclude
will also be ignored. Within the limits I just explained.