How to Find a DVC-Tracked File in the DVC Cache
DVC keeps every version of your data in its cache, but not under the names you gave the files: each file is named after its MD5 hash. Once you know that, you can find any tracked file in the cache in a few seconds. This guide finds a tracked file and a tracked folder in the cache with DVC 3.67.1, checks that the cached copy is the same file, and shows why you can't edit it.
Syntax
dvc cache dir
cat <cache dir>/files/md5/<first 2>/<other 30>
| Part | What it means |
|---|---|
dvc cache dir | Prints where the project's cache is. By default it's the .dvc/cache folder in the project |
<first 2> | The first two characters of the file's md5, from its .dvc file. They name a folder |
<other 30> | The other 30 characters of the md5. They're the file's name in the cache |
DVC's internal files page explains it: "DVC calculates the file hash, a 32 characters long string (usually MD5). The first two characters are used to name the directory inside the cache, and the rest become the file name of the cached file."
The Example
book-list is a Git repository where dvc init has run. It tracks data/books.csv, a list of two books, and the folder data/covers, with one small text file for each book, with dvc add.
Prerequisites
- DVC, in a Git repository where
dvc inithas run. Rundvc --versionto check; this guide uses DVC 3.67.1.
Step 1: Read the File's Hash
The hash is in the file's .dvc file:
cat data/books.csv.dvc
outs:
- md5: 8e459b5745608be993ce2cbbc1baf4a5
size: 64
hash: md5
path: books.csv

The md5 is 8e459b5745608be993ce2cbbc1baf4a5, so the cache folder is 8e and the file name is 459b5745608be993ce2cbbc1baf4a5.
Step 2: Find the Cache Folder
dvc cache dir
/Users/you/source/book-list/.dvc/cache

The dvc cache dir reference says: "If no path value is given, it prints the current path of the cache directory." This project uses the default, .dvc/cache. The command is the same in PowerShell.
Step 3: Find the File
List the 8e folder:
- bash / zsh
- PowerShell
ls .dvc/cache/files/md5/8e
Get-ChildItem -Name .dvc/cache/files/md5/8e
459b5745608be993ce2cbbc1baf4a5
There it is. Open it:
cat .dvc/cache/files/md5/8e/459b5745608be993ce2cbbc1baf4a5
title,author,year
Dune,Frank Herbert,1965
Emma,Jane Austen,1815

It's the book list. cat works in PowerShell too.
Step 4: Check It's the Same File
Compute the MD5 hash of both files:
- bash / zsh
- PowerShell
md5 data/books.csv .dvc/cache/files/md5/8e/459b5745608be993ce2cbbc1baf4a5
MD5 (data/books.csv) = 8e459b5745608be993ce2cbbc1baf4a5
MD5 (.dvc/cache/files/md5/8e/459b5745608be993ce2cbbc1baf4a5) = 8e459b5745608be993ce2cbbc1baf4a5
(Get-FileHash -Algorithm MD5 data/books.csv).Hash
(Get-FileHash -Algorithm MD5 .dvc/cache/files/md5/8e/459b5745608be993ce2cbbc1baf4a5).Hash
8E459B5745608BE993CE2CBBC1BAF4A5
8E459B5745608BE993CE2CBBC1BAF4A5

Both files have the hash from the .dvc file, so they have the same contents. md5 is the macOS command; on Linux it's md5sum. PowerShell prints the same hash in capital letters.
Step 5: See Why You Can't Edit It
- bash / zsh
- PowerShell
ls -l .dvc/cache/files/md5/8e/459b5745608be993ce2cbbc1baf4a5
-r--r--r-- 1 you staff 64 Dec 4 10:48 .dvc/cache/files/md5/8e/459b5745608be993ce2cbbc1baf4a5
(Get-Item .dvc/cache/files/md5/8e/459b5745608be993ce2cbbc1baf4a5).IsReadOnly
True
-r--r--r-- means read-only for everyone: r is read, and the missing w is write. Try to add a line to it:
echo 'Ulysses,James Joyce,1922' >> .dvc/cache/files/md5/8e/459b5745608be993ce2cbbc1baf4a5
zsh: permission denied: .dvc/cache/files/md5/8e/459b5745608be993ce2cbbc1baf4a5

bash says Permission denied the same way, after the file's path, and the file stays as it was. DVC does this on purpose: in DVC 3.67.1, the dvc-data package sets cache files to mode 0o444, read-only for everyone, so a saved version can't change by accident. Your data/books.csv stays editable. On this Mac, DVC links it to the cache with a reflink, which the large dataset page says doesn't "carry any risk of cache corruption since the file system takes care of copying the file if you try to edit it in place". To change the data, edit data/books.csv and run dvc add again.
A Tracked Folder in the Cache
A folder's .dvc file has one hash for the whole folder, ending in .dir:
cat data/covers.dvc
outs:
- md5: 9bd8f966b70e79956f5deaa229c0d1e3.dir
size: 28
nfiles: 2
hash: md5
path: covers
The same rule finds it: folder 9b, file d8f966b70e79956f5deaa229c0d1e3.dir.
cat .dvc/cache/files/md5/9b/d8f966b70e79956f5deaa229c0d1e3.dir
[{"md5": "fe97cabd88502fe2ac1debdaaad4ffc0", "relpath": "dune.txt"}, {"md5": "3d5bbabcc80de836a944057e95df6f0a", "relpath": "emma.txt"}]

The .dir file is a JSON list with one entry per file in the folder: its md5 and its relpath, the path inside the folder. Each of those files is in the cache under its own hash, in fe/ and 3d/. The internal files page says: "That's how DVC knows that the other two cached files belong in the directory."
List Everything in the Cache
- bash / zsh
- PowerShell
find .dvc/cache -type f
.dvc/cache/files/md5/9b/d8f966b70e79956f5deaa229c0d1e3.dir
.dvc/cache/files/md5/3d/5bbabcc80de836a944057e95df6f0a
.dvc/cache/files/md5/fe/97cabd88502fe2ac1debdaaad4ffc0
.dvc/cache/files/md5/8e/459b5745608be993ce2cbbc1baf4a5
Get-ChildItem -Recurse -File -Name .dvc/cache
files/md5/3d/5bbabcc80de836a944057e95df6f0a
files/md5/8e/459b5745608be993ce2cbbc1baf4a5
files/md5/9b/d8f966b70e79956f5deaa229c0d1e3.dir
files/md5/fe/97cabd88502fe2ac1debdaaad4ffc0

Four files: the book list, the two cover files, and the folder's .dir list. No file in the cache has its original name.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Searching the cache for a file's name | Nothing matches: cache files are named after their hash | Take the md5 from the .dvc file |
| Using all 32 characters as the file name | No such file | The first 2 are a folder, the other 30 the file name |
Editing a file inside .dvc/cache | permission denied | Edit the file in the project, then dvc add it |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
permission denied when writing to a cache file | Cache files are read-only on purpose | Leave them alone; change the project's file and dvc add it |
The .dir file is one long line | That's its format: JSON without line breaks | Read it as a list of md5 and relpath pairs |
FAQ
Why are there no file names in the cache?
Because the cache is organized by contents. The internal files page says: "file hashes are calculated from file contents only. 2 or more files with different names but the same contents can exist in the workspace and be tracked by DVC, but only one copy is stored in the cache."
Is the remote organized the same way?
Yes. A folder used as a remote has the same files/md5/<first 2>/<other 30> layout, as How to Upload Data to a DVC Remote with dvc push shows.
Conclusion
data/books.csv.dvc gave the hash 8e459b57…, dvc cache dir gave the cache's place, and the file was at .dvc/cache/files/md5/8e/459b57…, with the same MD5 hash as the project's copy and read-only. A tracked folder has a .dir file in the cache that lists each of its files by hash.
Additional Resources
- Internal files — "Structure of the cache directory".
- dvc cache dir — show or change where the cache is.
- Large dataset optimization — reflinks, hard links, symlinks and copies.
