.gitignore文件不忽略.env.local或任何其他假定的私人文件

发布于 2025-01-31 17:23:21 字数 90 浏览 1 评论 0原文

我遇到了此错误,因为我曾经错误地犯下.env.local,然后将其添加到.gitignore。下面的答案。

I encountered this error because I once mistakenly committed .env.local before adding it to .gitignore. The answer to it below.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悟红尘 2025-02-07 17:23:21

如果您面对类似的内容,并且在VSCODE中使用GIT GUI,请按照以下步骤:

  • 打开您的.env.local文件或任何有此问题的文件,请将内容复制到剪贴板,然后完全删除文件。
  • 打开您的.gitignore文件,然后删除删除该文件的行。
  • 提交您的更改(不一定是发布)。
  • 现在创建一个新的.env.local file(或您在案例中之前删除的文件。)
  • 切换到源控制选项卡(您在其中看到阶段文件),右键单击此新创建的文件和 现在将其添加到.gitignore

现在,将其忽略。

If you're facing something similar and you use the Git GUI in VSCode, just follow these steps:

  • Open your .env.local file or any file that's having this issue, copy the content to clipboard, and delete the file entirely.
  • Open your .gitignore file and delete the line that removes that file.
  • Commit your changes (not necessarily publish).
  • Now create a new .env.local file (or the file you deleted earlier in your case.)
  • Switch to your Source Control tab (where you see staged files), right click on this newly created file and add it to .gitignore

Now, it will be ignored for real.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文