Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git doesn't push .env file on the server

on my local server in my laravel app I have .env file.

to push changes to the server I use

git add . git commit -m "something" git push heroku master

but when I use heroku git:clone -a myapp in the cloned app there is no .env file... there is only .env.development file.

Do I do something wrong?

like image 466
Jakub Kohout Avatar asked Sep 25 '15 00:09

Jakub Kohout


People also ask

Does git ignore .env files?

The short answer is, “yes”. You should use your . gitignore file to ignore the . env file.

Should I push env to Git?

You shouldn't commit/include your . env file in your git repo because env stands for environment. You will different environment variables for your LOCAL, STAGING(development), PRODUCTION environments.

Should you push .env files?

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.


3 Answers

Check your .gitignore file if you have one there. If your git repo was set up for you automatically or imported from another project then it is likely that it is being ignored by default.

If it is in there then simply remove it to include your .env file in your next commit.

like image 79
James Avatar answered Sep 26 '22 12:09

James


Laravel, by default, ignores the .env - this is very much intended, as your different environments should technically have, well, different env files. It also helps you from not submitting credentials (such as for your database) into version control.

I would recommend you continue to follow this intended practice and look into using heroku config variables: https://devcenter.heroku.com/articles/config-vars

like image 29
Chris Avatar answered Sep 26 '22 12:09

Chris


Open file text .gitignore on root folder, git will skip file and folder in .gitignore. You just delete all text. Then review git status.

like image 36
Huynh Thai Hung Avatar answered Sep 29 '22 12:09

Huynh Thai Hung