laravel git 不会在服务器上推送 .env 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32773000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:24:01  来源:igfitidea点击:

git doesn't push .env file on the server

gitlaravelheroku

提问by Jakub Kohout

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

在我的 Laravel 应用程序的本地服务器上,我有 .env 文件。

to push changes to the server I use

将更改推送到我使用的服务器

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

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

but when I use heroku git:clone -a myappin the cloned app there is no .envfile... there is only .env.developmentfile.

但是当我heroku git:clone -a myapp在克隆的应用程序中使用时,没有.env文件......只有.env.development文件。

Do I do something wrong?

我做错了什么吗?

回答by James

Check your .gitignorefile 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.

.gitignore如果您有文件,请检查您的文件。如果您的 git repo 是自动为您设置的或从另一个项目导入的,那么它很可能在默认情况下被忽略。

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

如果它在那里,那么只需将其删除即可将您的.env文件包含在您的下一次提交中。

回答by Chris

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

默认情况下,Laravel 会忽略.env- 这是非常有意的,因为从技术上讲,您的不同环境应该具有不同的env文件。它还可以帮助您避免将凭证(例如您的数据库)提交到版本控制中。

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

我建议您继续遵循这种预期的做法并研究使用 heroku 配置变量:https://devcenter.heroku.com/articles/config-vars

回答by Huynh Thai Hung

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

.gitignore在根文件夹中打开文件文本,git 将跳过 .git 文件夹中的文件和文件夹.gitignore。您只需删除所有文本。然后查看 git status。

回答by Anantha Raju C

Make sure there are no spaces surrounding "=" in your environment file .env. Now try to push it.

确保环境文件中的“=”周围没有空格.env。现在尝试推动它。

Run heroku config:push --overwritebecause it won't overwrite existing variables by default.

运行,heroku config:push --overwrite因为默认情况下它不会覆盖现有变量。

If the problem still persists, try this heroku-config: It provides a way for you to push/pull your Heroku environment to use locally.

如果问题仍然存在,请尝试使用这个heroku-config:它为您提供了一种方法来推/拉您的 Heroku 环境以在本地使用。