Gitignore (.gitignore)
Create a .gitignore file with pre-configured patterns for Node.js projects, covering build output, editor files, and OS artifacts.
Why Use This Command?
- Prevents build artifacts,
node_modules, and OS junk files from cluttering Git history. - Ships with sensible defaults so new projects start with a clean ignore list.
- Reads custom ignore patterns from
nova.config.jsonso the same excludes apply on every run.
Requirements
- Node.js runtime — Use any Node.js LTS release.
- Project root — Run the command from the directory containing the top-level
package.json.
Usage
Options
| Flag | Description |
|---|---|
-d, --dry-run | Run without writing any files. |
-r, --replace-file | Overwrite the existing file instead of creating a .nova-backup copy. |
Config Fields
| Field | Description |
|---|---|
gitignore.projectExcludes | Custom ignore patterns appended under the Project Excludes section of the output. |
Output Files
| File | Description |
|---|---|
.gitignore | Git ignore rules for build output, editor files, and OS artifacts. |
How It Works
The command is non-interactive. It reads its customization from nova.config.json and writes .gitignore without prompting.
To change the custom patterns, edit them through nova utility initialize under the Ignores category, which manages gitignore.projectExcludes.
Template Output
The generator writes the bundled template covering build output, editor files, and OS artifacts. Any patterns under gitignore.projectExcludes are appended to the Project Excludes section.
When gitignore.projectExcludes is absent, the generator emits the template only.
Overriding a File Inside an Ignored Directory
Git does not allow negating a path inside a directory that is fully ignored with dir/. To track a specific file inside an ignored directory, add the following sequence to gitignore.projectExcludes:
!node_modules/
node_modules/*
!node_modules/my-local-package
This first un-ignores the directory itself, then re-ignores its contents with a wildcard, and finally un-ignores the specific path you want tracked.