Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
133 lines (101 sloc) 3.89 KB
title description
What not to commit
Your development tools generate a bunch of files. Not all of them should be committed.

When you put Dart source code in a repository—using the pub tool, GitHub, or another source code management system—don't include most of the files that your IDE or code editor, the pub tool, and other tools generate.

**Note:** Except where noted, this page discusses only source code repositories, _not_ app deployment. Some files that you wouldn't normally put in a repository are useful or essential when you deploy an app.

The rules

Don't commit the following files and directories created by pub:

{% prettify none %} .dart_tool/ .packages build/ pubspec.lock // Except for application packages {% endprettify %}

**Note:** The `.dart_tool` directory, which is new in Dart 2, is used by pub and other tools. It replaces the `.pub` directory as of the 2.0.0-dev.32.0 SDK release. The `.packages` file replaces the `packages` directories that early Dart 1.x versions produced.

Don't commit the API documentation directory created by dartdoc:

{% prettify none %} doc/api/ {% endprettify %}

Don't commit files and directories created by other development environments. For example, if your development environment creates any of the following files, consider putting them in a global ignore file:

{% prettify none %} *.iml // IntelliJ *.ipr // IntelliJ *.iws // IntelliJ .idea/ // IntelliJ .DS_Store // Mac {% endprettify %}

Avoid committing generated JavaScript files:

{% prettify none %} *.dart.js *.info.json # Produced by the --dump-info flag. *.js # When generated by dart2js. Don't specify *.js if your # project includes source files written in JavaScript. *.js_ *.js.deps * {% endprettify %}

For more details, read on.


As a rule, commit only the files that people need to use your package or source code repository. Including additional files is unnecessary, could be counterproductive, and might have security implications if you expose details about your machine's setup. In many source code repositories, the common practice is not to commit generated files, at all.

To avoid committing files that are specific to your personal workflow or setup, consider using a global ignore file (for example, .gitignore_global).

When you use pub from within a Git repo, pub ignores the same files that Git does. For example, if you run pub publish from a Git repo that has a .gitignore file containing *.js, then your published package won't contain *.js files.

For more information on .gitignore files, see the GitHub help page Ignoring files.


The .packages file contains a list of dependencies used by your application. Users of your code should generate their own packages information using pub get.

{% include packages-dir.html %}


The pubspec.lock file is a special case, similar to Ruby's Gemfile.lock.

For library packages, do not commit the pubspec.lock file.

For application packages, do commit pubspec.lock. This file is the recommended way for non-shared resources such as applications to manage their dependencies.


Don't commit JavaScript files generated by dart2js. Just be careful that you don't accidentally exclude source files written in JavaScript.

Calling dart2js without any flags generates out.js, but the tools that invoke dart2js often specify an output name, such as:

{% prettify none %} dart2js -o main.dart.js main.dart {% endprettify %}

For more information on generating and debugging JavaScript source for Dart apps, see the dart2js documentation.

You can’t perform that action at this time.