如何避免 prisma .env 文件的 git 同步
当我在项目中设置 prisma 时,请按照此 文章,我可以设置.env
并设置数据库url和密码。
之后,建立数据库连接并迁移一些表。但我想知道将 .env
添加到 .gitignore
是否有任何问题? 密码是硬编码的,并且不会推送此凭据。
如果有人遇到过这个问题或知道其他选择,请告诉我。
When I set up prisma
in my project, by following this article, I can set up .env
and set database url and password.
After that,DB connection was established and some tables were migrated. But I am wondering that Are there any problem to add .env
to .gitignore
?
password is hardcoded and this credentials are not pushed.
If someone has experienced this problems or know other options, will you please let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
强烈建议将
env
文件添加到.gitignore
中。执行 npx prisma init 应创建一个 .gitignore 文件和一个 .env 文件,同时创建 prisma 文件夹。默认行为是将 env 文件添加到 .gitignore 文件中,以便凭证不会意外推送到源代码管理。
这是参考 用于使用多个环境变量或使用没有任何环境变量的 prisma。
将
.env
添加到.gitignore
文件应该没有问题。It is strongly recommended that the
env
files are added to.gitignore
.Executing
npx prisma init
should create a.gitignore
file and a.env
file along with creatingprisma
folder. The default behaviour is that the env file gets added to the .gitignore file so that the credentials are not accidentally pushed to source control.Here is a reference for using multiple env variables or using prisma without any env variables.
There should be no issues on adding
.env
to.gitignore
file.