我修改了我的.env文件,然后在终端git status
中编写
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env
我希望.env文件中的更改是由git来实现的,所以我在.gitignore中添加了这一行:
/.env
现在,当我编写git status
时,我得到了结果:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env
modified: .gitignore
我现在能做什么?为什么吉蒂格诺不被忽视?
发布于 2022-09-16 06:18:27
git rm --cached .env
(允许.gitignore操作)的问题是,一旦提交并按下一个git pull
,每个人都会丢失下一个git pull
上的文件。
如果您需要具有本地.env
设置(这不应该是Git存储库的一部分),您可以:
#include
指令,这将允许您包含第二个文件.env.local (您可以安全地将该文件添加到.gitignore
中)。.env.tpl
(一个模板文件),而忽略.env
本身(因此使用git rm --cached .env
,但使用git .env.tpl
)内容过滤驱动程序的思想是在git checkout
/git switch
上自动生成基于.env.tpl
模板文件和本地(且被忽略的) .env.values
值文件的.env
文件。
请参阅"针对不同环境的Github私有回购管理包“作为这种方法的示例。
https://stackoverflow.com/questions/73740497
复制相似问题