How to avoid git sync of prisma .env files

Viewed 187

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.

1 Answers

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 creating prisma 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.

Related