How to Track a Large File with dvc add
Git isn't built for big data files: every version stays in the repository forever. dvc add takes a file out of Git's hands, keeps its contents in DVC's cache, and leaves a tiny .dvc text file for Git to track instead. This guide tracks one CSV file, reads the .dvc file line by line, commits it, and fixes the two errors you're most likely to see, with DVC 3.67.1.
Syntax
dvc add <file>
| Part | What it means |
|---|---|
dvc add | Hashes the file, copies it into DVC's cache, and writes <file>.dvc next to it |
<file> | The path of the file to track, from the current folder |
The dvc add reference adds: "The command will add the targets to .gitignore to prevent them from being committed to the Git repository".
The Example
shop-sales is a Git repository where dvc init has run. Its data/sales.csv holds a shop's daily sales, and it's about to grow far beyond what belongs in Git. The real file here is tiny, so the outputs stay short; the commands are the same for a file of several gigabytes.
Prerequisites
- DVC, in a Git repository where
dvc inithas run. Rundvc --versionto check; this guide uses DVC 3.67.1.
Step 1: See the File Git Wants to Add
git status --short
?? data/
?? means untracked: Git would add the whole data folder, data file and all.
Step 2: Track the File with DVC
dvc add data/sales.csv
100% Adding...|███████████████████████████████████████████████████████████|1/1 [00:00, 8.76file/s]
To track the changes with git, run:
git add data/.gitignore data/sales.csv.dvc
To enable auto staging, run:
dvc config core.autostage true

DVC copied the file into its cache, .dvc/cache, and made two small files for Git: data/sales.csv.dvc and data/.gitignore. The hint at the end is the next command to run.
Step 3: Read the .dvc File
cat data/sales.csv.dvc
outs:
- md5: 179cb6f809e6b6875de3f981f822a7c3
size: 75
hash: md5
path: sales.csv

This is all Git will ever store about the data. The .dvc files page describes each field:
| Field | Here | What it means |
|---|---|---|
md5 | 179cb6f8… | The file's MD5 hash, its fingerprint. Any change to the file changes it |
size | 75 | The file's size in bytes |
hash | md5 | The hash type; the page says "only md5 is currently supported" |
path | sales.csv | The tracked file, relative to the .dvc file's folder |
And the new .gitignore keeps the real file out of Git:
cat data/.gitignore
/sales.csv

Step 4: Commit the .dvc File
Run the command DVC suggested, then commit:
git add data/sales.csv.dvc data/.gitignore
git commit -m "Track sales.csv with DVC"
[main dee2398] Track sales.csv with DVC
2 files changed, 6 insertions(+)
create mode 100644 data/.gitignore
create mode 100644 data/sales.csv.dvc
To see exactly what Git now tracks, list its files:
git ls-files
.dvc/.gitignore
.dvc/config
.dvcignore
data/.gitignore
data/sales.csv.dvc

data/sales.csv.dvc is there, and data/sales.csv isn't: Git versions the pointer, and DVC keeps the data. Every command in this guide works unchanged in PowerShell.
Error: Already Tracked by SCM
A second file, data/prices.csv, had been committed to Git before DVC came along. dvc add refuses it:
dvc add data/prices.csv
Adding...
ERROR: output 'data/prices.csv' is already tracked by SCM (e.g. Git).
You can remove it from Git, then add to DVC.
To stop tracking from Git:
git rm -r --cached 'data/prices.csv'
git commit -m "stop tracking data/prices.csv"
The message has the fix. git rm --cached stops Git tracking the file without deleting it from your disk:
git rm -r --cached data/prices.csv
rm 'data/prices.csv'
git commit -m "Stop tracking prices.csv in Git"
[main cdb7de0] Stop tracking prices.csv in Git
1 file changed, 3 deletions(-)
delete mode 100644 data/prices.csv
dvc add data/prices.csv
100% Adding...|███████████████████████████████████████████████████████████|1/1 [00:00, 72.97file/s]
To track the changes with git, run:
git add data/prices.csv.dvc data/.gitignore
To enable auto staging, run:
dvc config core.autostage true

data/.gitignore now lists both files, /sales.csv and /prices.csv. The old versions of prices.csv stay in Git's history; only new versions go to DVC.
Error: Does Not Exist
A typo in the path, salse instead of sales, stops dvc add with the operating system's own error:
dvc add data/salse.csv
Adding...
ERROR: output 'data/salse.csv' does not exist: [Errno 2] No such file or directory: '/Users/you/source/shop-sales/data/salse.csv'
Check the name with ls data, and run it again.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Committing the data file to Git first | dvc add says it's already tracked by SCM (e.g. Git) | git rm -r --cached <file>, commit, then dvc add |
Committing only the .dvc file | data/.gitignore stays untracked, so the rule that keeps the data out of Git isn't shared with anyone who clones the repository | Add both files DVC names in its hint |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
output '...' is already tracked by SCM (e.g. Git) | Git tracks the file | The two commands in the message, then dvc add again |
output '...' does not exist: [Errno 2] No such file or directory | A wrong path | Fix the path; paths are relative to the current folder |
bad DVC file name '...' is git-ignored. | A .gitignore rule also ignores the .dvc file DVC wants to write | Fixed: "bad DVC file name '…' is git-ignored" When You Run dvc add |
FAQ
Where did the file's contents go?
Into .dvc/cache, under a name made from its MD5 hash. Your data/sales.csv is still in place, and you use it as before.
Can I stop DVC from printing the git add hint?
Yes: dvc config core.autostage true makes dvc add run the git add for you. The hint says so itself.
Does it work the same for a folder?
Yes, with one .dvc file for the whole folder; the folder guide below shows it.
Conclusion
dvc add data/sales.csv moved the file's contents into DVC's cache, kept the file out of Git with data/.gitignore, and left data/sales.csv.dvc, five lines with the file's MD5 hash and size, for Git to commit. A file Git already tracked needed git rm -r --cached first.
Additional Resources
- dvc add — every option, including
--no-commit. - .dvc files — every field a
.dvcfile can hold.
