如何恢复提交.gitignore后丢失的.env文件 [英] How do I recover a .env file that was gone after I commited a .gitignore

查看:411
本文介绍了如何恢复提交.gitignore后丢失的.env文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个名为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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆