Skip to main content

DVC: Version Datasets Alongside Git

Updated 2 min readMarkdown
Part of seriesMLOPS
DVC: Version Datasets Alongside Git

Git is excellent for source code, but large datasets and model files are often poor candidates for ordinary Git history. Data Version Control (DVC) helps manage these files while keeping Git as the source of truth for project history.

How DVC works

When you run:

dvc add data/raw/transactions.csv

DVC calculates a content hash, stores the file in its cache, and creates a small pointer file:

transactions.csv
transactions.csv.dvc

The .dvc file records metadata that identifies the data version. You commit that pointer file to Git, while the actual data is stored in DVC's cache or a configured remote.

This gives you two connected histories:

  • Git records which data version belongs to each code revision.
  • DVC stores and retrieves the corresponding data content.

Updating a dataset

If the CSV changes, run dvc add again and commit the updated .dvc pointer:

dvc add data/raw/transactions.csv
git add data/raw/transactions.csv.dvc
git commit -m "Update transaction dataset"

Older versions remain retrievable as long as their DVC cache or remote objects are retained.

Push and pull

A DVC remote stores data outside the Git repository:

dvc push

Another machine can retrieve the data referenced by the checked-out Git revision:

dvc pull

An S3-compatible object store can be used as a DVC remote. The endpoint and credentials must match the remote that is configured as the default.

Why this matters

A Git commit alone may not be enough to reproduce an ML result. You also need the exact dataset used by that code.

Takeaway: Git versions the project definition; DVC makes the associated data versions available.

No comments yet. Be the first to comment.