What Not to Commit

Send feedback

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

The rules

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

build/
packages/
pubspec.lock  // Except for application packages
.buildlog
.packages
.project
.pub/

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

doc/api/

Don’t commit files and directories dropped by other development environments. For example:

*.iml         // IntelliJ
*.ipr         // IntelliJ
*.iws         // IntelliJ
.idea/        // IntelliJ
.DS_Store     // Mac

Avoid committing generated JavaScript files:

*.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
*.js.map

For more details, read on.

Details

As a rule, you should 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 even 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.

See Ignoring files in the GitHub help for more information.

.packages and packages/

The .packages file contains a list of dependencies used by your application. Directories named packages/ contain symlinks specific to your machine. Users of your code should generate their own packages information using pub get.

pubspec.lock

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.

*.js

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:

dart2js -o main.dart.js main.dart

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