简体   繁体   English

冻结的文件被添加到提交中,忽略 gitignore

[英]Freezed files are added to the commit, ignoring gitignore

These are the lines in my.gitignore concerning the files generated by flutter pub run build_runner build --delete-conflicting-outputs这些是 my.gitignore 中关于flutter pub run build_runner build --delete-conflicting-outputs生成的文件的行

*.freezed.dart
*.g.dart 

I tried我试过了

git rm -rf --cached .
git add .

and still *.freezed.dart and *.g.dart get added again仍然*.freezed.dart*.g.dart再次添加

If I'm understanding your question correctly;如果我正确理解您的问题; if the files have been previously tracked by git then you need to remove the files then commit those changes to the repository to remove them from git but keeps the local copies.如果文件之前已被 git 跟踪,那么您需要删除文件,然后将这些更改提交到存储库以将它们从 git 中删除,但保留本地副本。

>git rm -rf --cached .
>git add .
>git commit -m "remove ignored files"

Check if the *.freezed.dart and *.g.dart which keep getting added again are part of a nested repository, or a submodule folder.检查不断添加的*.freezed.dart*.g.dart是否是嵌套存储库或子模块文件夹的一部分。

In both cases (nested or submodule), the .gitignore in the parent folder of those sub-repositories would not apply to said sub-repositories content.在这两种情况下(嵌套或子模块),这些子存储库的父文件夹中的.gitignore不适用于所述子存储库内容。

So go in the parent folder of one of those files and type: git rev-parse --show-toplevel所以 go 在这些文件之一的父文件夹中并键入: git rev-parse --show-toplevel

I don't understand why, but I changed我不明白为什么,但我改变了

*.freezed.dart
*.g.dart 

for为了

*.g.dart 
*.freezed.dart

and it started working它开始工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM