I have just started learning backend dev using django. My question is do I just commit the project files in the server folder alone, or should I also commit the .env
folder to the repository?
I have done the following:
config.json
to protect my API key..gitignore
.What happens if I do or do not commit .env
?
env files to version control (carefully) Many software projects require sensitive data which shouldn't be committed to version control. You don't want Bad Guys to read your usernames, passwords, API keys, etc.
No you don't. . env file should be put on server in a separated way. Otherwise whoever can access to your source code repository can read or even modify .
env file is placed at the base of the project directory. Project directory can be explicitly defined with the --file option or COMPOSE_FILE environment variable.
The short answer is, “yes”. You should use your . gitignore file to ignore the . env file.
Assuming that your .env
folder is your virtual environment, no you should not commit it.
The virtual environment should be rebuilt on the server using your requirements.txt
file. The local environment you built on your development machine may have operating system specific binaries, and other compiled code that was generated for your local environment.
The server will have different compiled binaries, and therefore should rebuild the virtual environment using: pip install -r requirements.txt
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With