即使该文件包含在 .gitignore 列表中也无法删除

问题描述 投票:0回答:1

我有一个 Flutter 项目,最初没有 .gitignore 文件。添加 .gitignore 文件并使用以下命令进行清理后:

git rm -r --cached .
git add .
git commit -m "fixed untracked files"

一开始它运行得很好,直到我的 Flutter 项目为 Android 构建了应用程序。然后,之前包含在.gitignore中的gradle文件夹中的几个文件又重新出现了。

6 files appeared

我再次运行上面的命令,文件消失了,但是当再次构建 apk 时,它们又出现了。

.gitignore:

# Do not remove or rename entries in this file, only add new ones
# See https://github.com/flutter/flutter/issues/128635 for more context.

# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Visual Studio Code related
.classpath
.project
.settings/
.vscode/*

# Flutter repo-specific
/bin/cache/
/bin/internal/bootstrap.bat
/bin/internal/bootstrap.sh
/bin/mingit/
/dev/benchmarks/mega_gallery/
/dev/bots/.recipe_deps
/dev/bots/android_tools/
/dev/devicelab/ABresults*.json
/dev/docs/doc/
/dev/docs/api_docs.zip
/dev/docs/flutter.docs.zip
/dev/docs/lib/
/dev/docs/pubspec.yaml
/dev/integration_tests/**/xcuserdata
/dev/integration_tests/**/Pods
/packages/flutter/coverage/
version
analysis_benchmark.json

# packages file containing multi-root paths
.packages.generated

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
pubspec.lock
.flutter-plugins-dependencies
**/generated_plugin_registrant.dart
.packages
.pub-preload-cache/
.pub-cache/
.pub/
build/
flutter_*.png
linked_*.ds
unlinked.ds
unlinked_spec.ds

# Android related
**/android/**/gradle-wrapper.jar
.gradle/
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
**/android/key.properties
*.jks

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/.last_build_id
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/ephemeral
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# macOS
**/Flutter/ephemeral/
**/Pods/
**/macos/Flutter/GeneratedPluginRegistrant.swift
**/macos/Flutter/ephemeral
**/xcuserdata/

# Windows
**/windows/flutter/generated_plugin_registrant.cc
**/windows/flutter/generated_plugin_registrant.h
**/windows/flutter/generated_plugins.cmake

# Linux
**/linux/flutter/generated_plugin_registrant.cc
**/linux/flutter/generated_plugin_registrant.h
**/linux/flutter/generated_plugins.cmake

# Coverage
coverage/

# Symbols
app.*.symbols

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/dev/ci/**/Gemfile.lock
!.vscode/settings.json
.fvmrc
.fvm
android/.gradle/**/executionHistory/executionHistory.bin
android/.gradle/**/executionHistory/executionHistory.lock
android/.gradle/**/fileHashes/fileHashes.bin
android/.gradle/**/fileHashes/fileHashes.lock
android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
android/.gradle/buildOutputCleanup/outputFiles.bin

也运行了相同的命令,并且 git 删除了这 6 个文件。但是,在构建 Android 文件时,这些文件又出现了。

flutter git gitignore
1个回答
0
投票

根据React Native gradleexecutionHistory.bintoobig,整个

.gradle
目录应该添加到
.gitignore

代替:

android/.gradle/**/executionHistory/executionHistory.bin
android/.gradle/**/executionHistory/executionHistory.lock
android/.gradle/**/fileHashes/fileHashes.bin
android/.gradle/**/fileHashes/fileHashes.lock
android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
android/.gradle/buildOutputCleanup/outputFiles.bin

尝试:

android/.gradle

或者,作为替代方案:

.gradle

另请参阅react-native/.gitignore

© www.soinside.com 2019 - 2024. All rights reserved.