是否有可能根据环境变量来改变.gitignore [英] Is it possible to make .gitignore changed according to environment variables
问题描述
例如
<$ p $是否可以添加到.gitignore规则取决于环境变量?如果-e $(ENV_VAR)AAA
!liba.so
else
liba.so
如果ENV_VAR =AAA,基本上我想拥有一个 / pre>
本地存储库将有
a.txt
,如果 ENV_VAR
没有设置a.txt将被删除。
答案是否定的。 b
$ b
Gitignore规则完全是静态的。此外,这甚至没有任何意义。一旦文件进入回购站,gitignore不再适用 - 它只能防止添加新的文件。
,你可以有一个本地的gitignore: .git / info / exclude
中的任何内容也将被忽略。在我刚刚解释的范围内。
Is it possible to add to .gitignore rules depends on environment variables?
for example
if -e $(ENV_VAR) "AAA"
!liba.so
else
liba.so
Basically what I want is to have a repository such that if ENV_VAR = "AAA"
the local repository will have a.txt
and if ENV_VAR
isn't set the a.txt will be removed.
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.
这篇关于是否有可能根据环境变量来改变.gitignore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!