I created a branch called chat-feature
but when I merged it in my master suddenly I found my .env file is gone..
Asked
Active
Viewed 3,677 times
0

TheBAST
- 2,680
- 10
- 40
- 68
-
Your `.env` file should not be committed to your application's source control, since each developer/server using your application could require a different environment configuration. Furthermore, this would be a security risk in the event an intruder gains access to your source control repository, since any sensitive credentials would get exposed. https://laravel.com/docs/6.x/configuration#environment-configuration. You can leave the .env.example in the repository only with the necessary keys but without the values. – porloscerros Ψ Nov 09 '19 at 12:53
-
totally, that's why I added it in on my .gitignore, I think it's already there when laravel was already installed, the thing that pisses me is that it just got lost along the way or I deleted it , I don't know probably I can go back to an old version of this master branch, is it possible ? – TheBAST Nov 09 '19 at 14:57
-
As you say, the .env is already in .gitignore in the laravel repository / installation, so the file was never included in git if you didn't change that setting. Maybe you accidentally deleted / moved it. I think your best chance is that your system has a trash folder where the deleted files go before being permanently deleted, or if you have moved it to another directory without noticing it, you can do a search with your ide to see if it is somewhere else (find in path with phpstorm) – porloscerros Ψ Nov 09 '19 at 16:03
1 Answers
1
Go back to your previous branch: git checkout master
(or replace master
by the name of the previous branch where your .env
file is).
You can now make a copy of the file.
Also, check that your .gitignore
to see if .env
is listed or not. If your git repo was set up for you automatically or if it was 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 the .env
file in your next commit.
I would not recommend pushing a .env
file, unless your repo is private and you are sure about what you are doing.

pimarc
- 3,621
- 9
- 42
- 70
-
totally, that's why I added it in on my .gitignore, I think it's already there when laravel was already installed, the thing that pisses me is that it just got lost along the way or I deleted it , I don't know probably I can go back to an old version of this master branch, is it possible ? – TheBAST Nov 09 '19 at 14:58
-
Yes, you could go back in history with `git checkout 12345679` using a previous git commit (see this answer: https://stackoverflow.com/questions/4114095/how-do-i-revert-a-git-repository-to-a-previous-commit) – pimarc Nov 09 '19 at 15:03