Skip to main content

Synopsis

Description

The dvc commit command records changes to files or directories tracked by DVC by storing the current versions in the cache. It updates the hash values in .dvc files or dvc.lock to match the current workspace state. Use dvc commit when:
  • You’ve modified tracked data files and want to save the new version
  • You used dvc add --no-commit and now want to commit the data to cache
  • You’ve updated outputs of a DVC pipeline stage and want to persist them
  • You need to update .dvc file metadata to reflect current file state
The commit operation:
  1. Computes hashes of the current workspace files
  2. Moves/copies the files into the DVC cache
  3. Updates .dvc or dvc.lock files with new hash values
  4. Creates links from cache back to workspace
Unlike Git’s commit, dvc commit doesn’t create a new version history entry. It updates the current tracking state. Version history is maintained through Git commits of the .dvc files.

Options

path
Limit command scope to specific tracked files/directories, .dvc files, or stage names. If not specified, commits all changed tracked data.
boolean
default:"false"
Commit data even if hash values for dependencies or outputs did not change. Forces a recommit of the data.
Use this when you want to ensure data is in cache even if DVC thinks nothing changed.
boolean
default:"false"
Commit all dependencies of the specified target. Useful for pipeline stages that depend on other stages.
boolean
default:"false"
Commit cache for subdirectories of the specified directory.
Don’t recreate links from cache to workspace after committing.
By default, after committing files to cache, DVC recreates the workspace files as links to the cache to save space.

Examples

Basic commit

Commit all modified tracked files:

Commit specific files

Commit only specific targets:

Commit after modifying data

Typical workflow when updating tracked data:

Commit after add —no-commit

When you used --no-commit during add:

Force commit

Force a commit even when DVC thinks nothing changed:
This will recompute hashes and move data to cache even if the file appears unchanged.

Commit pipeline outputs

Commit outputs from a DVC pipeline stage:

Recursive commit

Commit all .dvc files in a directory:

Example workflows

Workflow 1: Update tracked data

Workflow 2: Pipeline development

Workflow 3: Batch operations

Understanding the difference from Git

Best practice: After dvc commit, always git commit the updated .dvc files to create a version history entry.

Handling changes

When you commit, DVC may prompt you to confirm changes:
To skip the prompt, use --force:

Performance considerations

Commit specific targets - Instead of committing everything with dvc commit, specify targets to avoid unnecessary hash computations for unchanged files.
Use —no-relink for speed - If you don’t need workspace files updated, use --no-relink to skip the relinking step.
  • dvc add - Start tracking new files
  • dvc checkout - Update workspace from cache
  • dvc push - Upload committed data to remote storage
  • dvc status - Check which files have changed