Flutter 项目中哪些文件和目录应该被忽略?

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

我必须从头开始创建一个新的 Flutter 项目并将其推送到 GitGub。 因此,作为第一步,我通过以下方式创建了一个新的 git 存储库:

git init

我从 Flutter GitHub 存储库复制了 .gitignore,添加了一些特定的文件和文件夹:

# Dart/Flutter
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
# If you're building an application, you may want to check-in your pubspec.lock
#pubspec.lock

# 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
.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/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

# macOS Files
.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# Visual Studio Code
.vscode/
*.code-workspace

# Visual Studio Code - Workspace Settings
.vscode/settings.json
.vscode/tasks.json
.vscode/launch.json
.vscode/extensions.json

# Visual Studio
.vs/
*.user
*.userosscache
*.suo
*.userprefs
*.pdb
*.vsp
*.vspx
*.builds
*.pidb
*.svclog
*.scc

# TFS 2012 Local Workspace
$tf/

然后添加到git中:

git add .gitignore

然后

commit
push

此时,我认为 git 已正确设置为忽略通用 Flutter 项目的文件和文件夹。

因此,下一步是创建一个新的 flutter 项目;我使用了

Visual Studio Code
命令
flutter new
并将整个项目添加到 git:

git add ./*

因此,为了在提交之前确定,我想检查哪些文件和文件夹已被隐藏:

git status

这是输出:

    On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   flutter_calendar/.gitignore
        new file:   flutter_calendar/.metadata
        new file:   flutter_calendar/README.md
        new file:   flutter_calendar/analysis_options.yaml
        new file:   flutter_calendar/android/.gitignore
        new file:   flutter_calendar/android/app/build.gradle
        new file:   flutter_calendar/android/app/src/debug/AndroidManifest.xml
        new file:   flutter_calendar/android/app/src/main/AndroidManifest.xml
        new file:   flutter_calendar/android/app/src/main/kotlin/com/example/flutter_calendar/MainActivity.kt
        new file:   flutter_calendar/android/app/src/main/res/drawable-v21/launch_background.xml
        new file:   flutter_calendar/android/app/src/main/res/drawable/launch_background.xml
        new file:   flutter_calendar/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
        new file:   flutter_calendar/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
        new file:   flutter_calendar/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
        new file:   flutter_calendar/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
        new file:   flutter_calendar/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
        new file:   flutter_calendar/android/app/src/main/res/values-night/styles.xml
        new file:   flutter_calendar/android/app/src/main/res/values/styles.xml
        new file:   flutter_calendar/android/app/src/profile/AndroidManifest.xml
        new file:   flutter_calendar/android/build.gradle
        new file:   flutter_calendar/android/gradle.properties
        new file:   flutter_calendar/android/gradle/wrapper/gradle-wrapper.properties
        new file:   flutter_calendar/android/settings.gradle
        new file:   flutter_calendar/ios/.gitignore
        new file:   flutter_calendar/ios/Flutter/AppFrameworkInfo.plist
        new file:   flutter_calendar/ios/Flutter/Debug.xcconfig
        new file:   flutter_calendar/ios/Flutter/Release.xcconfig
        new file:   flutter_calendar/ios/Runner.xcodeproj/project.pbxproj
        new file:   flutter_calendar/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
        new file:   flutter_calendar/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
        new file:   flutter_calendar/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
        new file:   flutter_calendar/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
        new file:   flutter_calendar/ios/Runner.xcworkspace/contents.xcworkspacedata
        new file:   flutter_calendar/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
        new file:   flutter_calendar/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
        new file:   flutter_calendar/ios/Runner/AppDelegate.swift
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/LaunchImage.imageset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/LaunchImage.imageset/[email protected]
        new file:   flutter_calendar/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md
        new file:   flutter_calendar/ios/Runner/Base.lproj/LaunchScreen.storyboard
        new file:   flutter_calendar/ios/Runner/Base.lproj/Main.storyboard
        new file:   flutter_calendar/ios/Runner/Info.plist
        new file:   flutter_calendar/ios/Runner/Runner-Bridging-Header.h
        new file:   flutter_calendar/ios/RunnerTests/RunnerTests.swift
        new file:   flutter_calendar/lib/main.dart
        new file:   flutter_calendar/linux/.gitignore
        new file:   flutter_calendar/linux/CMakeLists.txt
        new file:   flutter_calendar/linux/flutter/CMakeLists.txt
        new file:   flutter_calendar/linux/main.cc
        new file:   flutter_calendar/linux/my_application.cc
        new file:   flutter_calendar/linux/my_application.h
        new file:   flutter_calendar/macos/.gitignore
        new file:   flutter_calendar/macos/Flutter/Flutter-Debug.xcconfig
        new file:   flutter_calendar/macos/Flutter/Flutter-Release.xcconfig
        new file:   flutter_calendar/macos/Runner.xcodeproj/project.pbxproj
        new file:   flutter_calendar/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
        new file:   flutter_calendar/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
        new file:   flutter_calendar/macos/Runner.xcworkspace/contents.xcworkspacedata
        new file:   flutter_calendar/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
        new file:   flutter_calendar/macos/Runner/AppDelegate.swift
        new file:   flutter_calendar/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
        new file:   flutter_calendar/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
        new file:   flutter_calendar/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
        new file:   flutter_calendar/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
        new file:   flutter_calendar/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
        new file:   flutter_calendar/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
        new file:   flutter_calendar/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
        new file:   flutter_calendar/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
        new file:   flutter_calendar/macos/Runner/Base.lproj/MainMenu.xib
        new file:   flutter_calendar/macos/Runner/Configs/AppInfo.xcconfig
        new file:   flutter_calendar/macos/Runner/Configs/Debug.xcconfig
        new file:   flutter_calendar/macos/Runner/Configs/Release.xcconfig
        new file:   flutter_calendar/macos/Runner/Configs/Warnings.xcconfig
        new file:   flutter_calendar/macos/Runner/DebugProfile.entitlements
        new file:   flutter_calendar/macos/Runner/Info.plist
        new file:   flutter_calendar/macos/Runner/MainFlutterWindow.swift
        new file:   flutter_calendar/macos/Runner/Release.entitlements
        new file:   flutter_calendar/macos/RunnerTests/RunnerTests.swift
        new file:   flutter_calendar/pubspec.yaml
        new file:   flutter_calendar/web/favicon.png
        new file:   flutter_calendar/web/icons/Icon-192.png
        new file:   flutter_calendar/web/icons/Icon-512.png
        new file:   flutter_calendar/web/icons/Icon-maskable-192.png
        new file:   flutter_calendar/web/icons/Icon-maskable-512.png
        new file:   flutter_calendar/web/index.html
        new file:   flutter_calendar/web/manifest.json
        new file:   flutter_calendar/windows/.gitignore
        new file:   flutter_calendar/windows/CMakeLists.txt
        new file:   flutter_calendar/windows/flutter/CMakeLists.txt
        new file:   flutter_calendar/windows/runner/CMakeLists.txt
        new file:   flutter_calendar/windows/runner/Runner.rc
        new file:   flutter_calendar/windows/runner/flutter_window.cpp
        new file:   flutter_calendar/windows/runner/flutter_window.h
        new file:   flutter_calendar/windows/runner/main.cpp
        new file:   flutter_calendar/windows/runner/resource.h
        new file:   flutter_calendar/windows/runner/resources/app_icon.ico
        new file:   flutter_calendar/windows/runner/runner.exe.manifest
        new file:   flutter_calendar/windows/runner/utils.cpp
        new file:   flutter_calendar/windows/runner/utils.h
        new file:   flutter_calendar/windows/runner/win32_window.cpp
        new file:   flutter_calendar/windows/runner/win32_window.h

我无法判断是否应忽略先前输出中的某些文件和文件夹;你能帮我改进 .gitignore 文件吗?

flutter git dart gitignore
1个回答
0
投票

所有新文件都在里面

flutter_calendar
。所以你可以将其添加到 .gitignore:

flutter_calendar/

提交并运行

git status

再次

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