如何恢复提交.gitignore后丢失的.env文件 [英] How do I recover a .env file that was gone after I commited a .gitignore
问题描述
我创建了一个名为chat-feature
的分支,但是当我将其合并到我的母版中时,突然发现我的.env文件消失了..
返回上一个分支:git checkout master
(或用.env
文件所在的上一个分支的名称替换master
). /p>
您现在可以复制文件了.
此外,检查您的.gitignore
以查看是否列出了.env
.如果您的git repo是自动为您设置的,或者是从另一个项目导入的,则默认情况下很可能会忽略它.
如果在其中,则只需将其删除以在您的下一次提交中包含.env
文件.
我不建议推送.env
文件,除非您的回购是私人的,并且您确定自己在做什么.
I created a branch called chat-feature
but when I merged it in my master suddenly I found my .env file is gone..
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.
这篇关于如何恢复提交.gitignore后丢失的.env文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!