Skip to content

Consistent .gitignore for Dart and Flutter projects #13892

Open
@timsneath

Description

@timsneath

We should have a standard and consistent .gitignore file common to Dart and Flutter that combines the recommendations currently on GitHub with those generated by flutter create (which are different).

From https://github.com/github/gitignore/blob/master/Dart.gitignore:

# See https://www.dartlang.org/tools/private-files.html

# Files and directories created by pub
.packages
.pub/
build/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock

# Directory created by dartdoc
# If you don't generate documentation locally you can remove this line.
doc/api/

From flutter create:

.DS_Store
.atom/
.idea
.packages
.pub/
build/
ios/.generated/
packages
pubspec.lock
.flutter-plugins

Other relevant fodder:
https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore
https://github.com/github/gitignore/blob/master/Global/Xcode.gitignore

Activity

matejthetree

matejthetree commented on Feb 26, 2018

@matejthetree

+1

What gitignore do you recomend to use atm with flutter projects, also with IntelliJ

natebosch

natebosch commented on Feb 26, 2018

@natebosch
Contributor

See also dart-lang/sdk#32030 which replaces .pub/ with .dart_tool/ in the ignore.

yoryer

yoryer commented on Apr 17, 2018

@yoryer

You can use https://www.gitignore.io to generate dynamic gitignore files based on different editors/languages.

fmatosqg

fmatosqg commented on Apr 17, 2018

@fmatosqg
Contributor

I'm still unsure if we should commit .iml files, specially after reading https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md

If you plan on using IntelliJ as your IDE, then also run flutter ide-config --overwrite to create all of the IntelliJ configuration files so you can open the main flutter directory as a project and run examples from within the IDE.

That's specifically for contributing to flutter sdk, but in my experience that's not necessary for either sdk, packages or app development.

added
toolAffects the "flutter" command-line tool. See also t: labels.
and removed
toolAffects the "flutter" command-line tool. See also t: labels.
on Apr 23, 2018
saschpe

saschpe commented on May 5, 2018

@saschpe

github/gitignore#2692 for adding Flutter rules to gitignore going forward.

I suggest using https://github.com/simonwhitaker/gibo for generating .gitignore files in your projects. With the above pull-request, getting proper rules boils down to

gibo Android Dart Flutter Linux JetBrains macOS Vim Xcode > .gitignore

jeroen-meijer

jeroen-meijer commented on May 13, 2018

@jeroen-meijer

Maybe it's a good idea to add GoogleService-Info.plist to the eventual Flutter gitignore as well.

zoechi

zoechi commented on May 13, 2018

@zoechi
Contributor

.pub is now .dart_tool

saschpe

saschpe commented on May 14, 2018

@saschpe

@jeroen-meijer: To keep it aligned with Android it would include android/*/google-services.json as well. I can adjust the patch accordingly

jeroen-meijer

jeroen-meijer commented on May 14, 2018

@jeroen-meijer
secondstreetmedia

secondstreetmedia commented on Sep 25, 2018

@secondstreetmedia

Is using https://github.com/simonwhitaker/gibo still a reasonable way to go? Using the example from @saschpe above, gibo does not currently appear to have Flutter as one of it's boilerplates.

➜  ~ gibo dump Android Dart Flutter JetBrains macOS Xcode >> .gitignore
Unknown argument: Flutter

Also, would adding any of the following be recommended: Archives, Backup, DartEditor, Java, JEnv, Kotlin, Maven, Objective-C, or any others from the list below:

➜  ~ gibo list
=== Languages ===

Actionscript		Go			Processing
Ada			Godot			PureScript
Agda			Gradle			Python
Android			Grails			Qooxdoo
AppceleratorTitanium	GWT			Qt
AppEngine		Haskell			R
ArchLinuxPackages	Idris			Rails
Autotools		IGORPro			RhodesRhomobile
C++			Java			ROS
C			Jboss			Ruby
CakePHP			Jekyll			Rust
CFWheels		Joomla			Sass
ChefCookbook		Julia			Scala
Clojure			KiCad			Scheme
CMake			Kohana			SCons
CodeIgniter		Kotlin			Scrivener
CommonLisp		LabVIEW			Sdcc
Composer		Laravel			SeamGen
Concrete5		Leiningen		SketchUp
Coq			LemonStand		Smalltalk
CraftCMS		Lilypond		Stella
CUDA			Lithium			SugarCRM
D			Lua			Swift
Dart			Magento			Symfony
Delphi			Maven			SymphonyCMS
DM			Mercury			Terraform
Drupal			MetaProgrammingSystem	TeX
Eagle			Nanoc			Textpattern
Elisp			Nim			TurboGears2
Elixir			Node			Typo3
Elm			Objective-C		Umbraco
EPiServer		OCaml			Unity
Erlang			Opa			UnrealEngine
ExpressionEngine	OpenCart		VisualStudio
ExtJs			OracleForms		VVVV
Fancy			Packer			Waf
Finale			Perl			WordPress
ForceDotCom		Perl6			Xojo
Fortran			Phalcon			Yeoman
FuelPHP			PlayFramework		Yii
Gcov			Plone			ZendFramework
GitBook			Prestashop		Zephir

=== Global ===

Anjuta			JDeveloper		Redcar
Ansible			JEnv			Redis
Archives		JetBrains		SBT
Backup			Kate			SlickEdit
Bazaar			KDevelop4		Stata
BricxCC			Lazarus			SublimeText
Calabash		LibreOffice		SVN
Cloud9			Linux			SynopsysVCS
CodeKit			LyX			Tags
CVS			macOS			TextMate
DartEditor		Matlab			TortoiseGit
Diff			Mercurial		Vagrant
Dreamweaver		MicrosoftOffice		Vim
Dropbox			ModelSim		VirtualEnv
Eclipse			Momentics		VisualStudioCode
EiffelStudio		MonoDevelop		WebMethods
Emacs			NetBeans		Windows
Ensime			Ninja			Xcode
Espresso		NotepadPP		XilinxISE
FlexBuilder		Otto
GPG			Patch
➜  ~
timsneath

timsneath commented on Sep 25, 2018

@timsneath
ContributorAuthor

We've updated the .gitignore file created by flutter create to be much more inclusive (PR #21192). Flutter projects moving forward should get a better default, but we should integrate this back into the GitHub gitignore repo.

@secondstreetmedia didn't know about this utility - cool idea. Adds to the value of fixing this issue.

37 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.team-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @saschpe@xster@frr149@zoechi@Hixie

        Issue actions

          Consistent .gitignore for Dart and Flutter projects · Issue #13892 · flutter/flutter