How to Compare Data Versions with dvc diff
git diff on a .dvc file shows only that a hash changed. dvc diff tells you which data files were added, modified or deleted, even inside a tracked folder. This guide compares the project folder with the last commit, then two commits, then prints the result as a Markdown table, with DVC 3.67.1.
Syntax
dvc diff [--md] [<a_rev>] [<b_rev>]
| Part | What it means |
|---|---|
dvc diff | Lists the DVC-tracked files and folders that were added, modified or deleted |
--md | Optional: prints the list as a Markdown table |
<a_rev> | Optional: the older Git revision, such as a commit hash, a branch name or HEAD~1. Without it, DVC uses HEAD, the last commit |
<b_rev> | Optional: the newer revision. Without it, DVC uses the project folder as it is now |
The dvc diff reference says: "It defaults to comparing the current workspace and the last commit (HEAD), if arguments a_rev and b_rev are not specified."
The Example
survey-results is a Git repository where dvc init has run. It tracks two things with dvc add: data/answers.csv, the answers of a small survey that Ana and Ben have filled in, and the folder data/forms, with one form file for each person. Both are committed, so dvc diff prints nothing yet.
Prerequisites
- DVC, in a Git repository where
dvc inithas run. Rundvc --versionto check; this guide uses DVC 3.67.1.
Step 1: Change the Data and Compare
Cara answers the survey too. Add her line to the answers and her form to the folder:
- bash / zsh
- PowerShell
echo "Cara,yes" >> data/answers.csv
echo "Form 3: Cara" > data/forms/form-3.txt
Add-Content data/answers.csv "Cara,yes"
Set-Content data/forms/form-3.txt "Form 3: Cara"
Compare the project folder with the last commit:
dvc diff
Added:
data/forms/form-3.txt
Modified:
data/answers.csv
data/forms/
files summary: 1 added, 1 modified

dvc diff looks inside the tracked folder:
- Added:
data/forms/form-3.txt: a new file insidedata/forms. - Modified:
data/answers.csv: the file has a new line, so its hash changed. - Modified:
data/forms/: the folder changed because it holds a new file. The trailing/marks a folder. files summarycounts files only, so the folder isn't in it.
The PowerShell lines gave byte-for-byte the same files, and the same dvc diff output, in PowerShell 7.6 on macOS.
Step 2: Save the Change and Compare Again
Save the new version of both, and commit the two .dvc files:
dvc add data/answers.csv data/forms
100% Adding...|███████████████████████████████████████████████████████████|2/2 [00:00, 97.17file/s]
To track the changes with git, run:
git add data/answers.csv.dvc data/forms.dvc
To enable auto staging, run:
dvc config core.autostage true
git commit -am "Add Cara's answer and form"
[main f21beb6] Add Cara's answer and form
2 files changed, 5 insertions(+), 5 deletions(-)
-a stages every changed file Git already tracks, here the two .dvc files, before it commits. Compare again:
dvc diff

dvc diff prints nothing now: the project folder matches the last commit. The commands are the same in PowerShell.
Step 3: Compare Two Commits
To see what a commit changed, compare it with the one before it. List the commits first:
git log --oneline
f21beb6 (HEAD -> main) Add Cara's answer and form
2d78992 Track the survey answers and forms
189a014 Initialize DVC
Then compare the last commit, HEAD, with the one before it, HEAD~1:
dvc diff HEAD~1 HEAD
Added:
data/forms/form-3.txt
Modified:
data/answers.csv
data/forms/
files summary: 1 added, 1 modified

HEAD is the last commit, f21beb6, and HEAD~1 is the one before it, 2d78992. The result is the same list as in Step 1, because that commit saved exactly those changes. The reference says both revisions accept "any Git revision - branch or tag name, Git commit hash, etc." The commands are the same in PowerShell.
Step 4: Print a Markdown Table
dvc diff --md HEAD~1 HEAD
| Status | Path |
|----------|-----------------------|
| added | data/forms/form-3.txt |
| modified | data/answers.csv |
| modified | data/forms/ |

Paste it into a pull request, an issue or a README, and it shows as a table:
| Status | Path |
|---|---|
| added | data/forms/form-3.txt |
| modified | data/answers.csv |
| modified | data/forms/ |
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Using git diff to see data changes | It shows only a changed hash in a .dvc file | dvc diff |
| Taking no output for an error | It means nothing changed between the two | Check the revisions with git log --oneline |
| Putting the newer commit first | dvc diff HEAD HEAD~1 lists the new form as Deleted | The older revision first, then the newer one |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
dvc diff prints nothing | No DVC-tracked file changed | Expected; compare other revisions if you meant to |
A folder is listed as Modified | A file inside it was added, changed or removed | The file's own line, above or below, says which |
FAQ
Does dvc diff show which lines changed?
No. It lists files, not lines. To read an earlier version of a file, get it back with git checkout and dvc checkout, as How to Go Back to an Earlier Version of Your Data with dvc checkout shows.
Can it show the hashes?
Yes: the reference says --show-hash prints "file and directory hash values along with their path".
Conclusion
dvc diff compared the project folder with the last commit and listed the new form as added and the answers and the forms folder as modified. After dvc add and a commit it printed nothing, dvc diff HEAD~1 HEAD showed what that commit changed, and --md printed the same list as a Markdown table.
Additional Resources
- dvc diff — every option, including
--json,--show-hashand--targets.
