Sub topic 1
Why Git Is Not Enough for Data and Models
Git is excellent for versioning source code, configuration, and small text files. It stores each commit as a snapshot of the project history. That history makes it easy to review code changes, create branches, and return to an earlier commit.
Machine learning projects also depend on datasets, generated features, and trained model files. These files create problems when they are stored directly in Git. This chapter explains those problems and the working model that DVC uses to address them.
Prerequisites
You should be comfortable with basic Git commands such as commit, branch, tag, and checkout. You should also understand that a machine learning model is produced from data, code, and training settings.
The limits of ordinary Git
A dataset can contain millions of rows, images, audio files, or other large binary objects. A trained model can also be large. Git can store these files, but storing them does not make Git efficient for them.
Git history is append-only in normal use. When a large file changes, Git keeps enough information to recover both versions. For text files, Git can often store a compact difference. For binary files, such as many model formats, a useful line-by-line difference usually does not exist. Each changed version can therefore add substantial storage.
The repository becomes larger even when the current working tree contains only one copy of the file. Every new clone may need to download much of that history. Developers then wait longer for clones, pulls, and continuous integration jobs.
Deleting a large file in a later commit does not remove it from earlier commits. The file may disappear from the current branch while remaining in the repository's history. Removing it completely requires specialized history rewriting, which can disrupt other clones and shared branches.
| Project item | What Git handles well | Common problem when stored directly |
|---|---|---|
| Python source | Text diffs and code review | Usually no major issue |
| A large image dataset | Version identity | Large clones and slow transfers |
| A binary model | Commit history | Poor diffs and repeated storage |
| Generated features | Reproducibility reference | Easily confused with source data |
Why data and model versions must match
A model is meaningful only with the data and process that produced it. If you check out an older training script but keep a newer dataset, you may not be able to reproduce the old result. The same problem occurs when a model file is copied outside Git and its origin is forgotten.
A useful version must answer questions such as:
- Which exact dataset produced this model?
- Which code and parameters were used?
- Can another developer obtain the same inputs?
- Can a previous release be restored without manually finding files?
Git can identify the code and small configuration files. It is less suitable as the main store for the large inputs and outputs. The project needs a separate mechanism that records exact file identities while keeping large content outside ordinary Git history.
The DVC working model
DVC, or Data Version Control, adds that mechanism. DVC stores small pointer files in Git. A pointer file records the identity of a data or model file, rather than embedding the file's contents in the Git repository.
The actual content is kept in a local DVC cache and, when configured, in remote storage. Git versions the pointer files. DVC uses the pointers to find, retrieve, and restore the matching content.
This separation keeps Git history small while preserving version identity. A commit can refer to a precise dataset and model without storing their full bytes in every Git operation.
DVC does not make an unreliable dataset reproducible by itself. You still need clear data collection rules, stable preprocessing code, and recorded training parameters. DVC supplies the versioned connection between those parts.
Exercise
Why can checking out an older Git commit fail to restore the older machine learning dataset when the dataset was stored outside Git?
Show answer
Git can restore the code and configuration it knows about, but it has no versioned reference or retrieval mechanism for the external dataset. DVC adds a pointer that identifies the required data version.