I have a .env file (I am using next.js and node.js, where each have their own .env), where some content are different for development and deployment.
For development:
DOMAIN_URL=https://localhost:3000
GOOGLE_CLIENT_ID='abc'
For deployment:
DOMAIN_URL=https://www.example.com
GOOGLE_CLIENT_ID='def'
I hope to make it easy by setting a flag say
DEV_FLAG=dev or DEV_FLAG=production
and according to the DEV_FLAG the .env can be set accordingly,
.env file?.env for different context?.env file is not meant to be commited in repo. It is meant to be added before running app. It should be ignored by VCS by adding .env line to .gitignore or .hgignore file.
.env file contains potentially secret values and you don't want to have them in repo for everyone to see.
You can commit example.env for deployers to see which env variables are available. Deployer/DevOp will run cp example.env .env, then edit .env file and run application.
You can commit default.env and load it in application before loading .env file for some sane not secret default values for tests or some generic (localhost) deploy environment.
But .env file should be original in each deploy.
You could set some flag DEV_FLAG=dev or DEV_FLAG=prod and in application change some behaviour based on its value, but generally I would not recommend it because it hides consequences.
Maybe you are developing on one pc and want to switch .env values. You can have more lines in file and comment them out as needed or you can have prod.env or local.env files and cp local.env .env as needed while having them ignored in .gitignore.
More about this topic you can read here: https://www.12factor.net/config