# DVC（数据版本控制）

DVC（Data Version Control，数据版本控制）是一款免费、开源的命令行工具，用于数据管理、机器学习流水线自动化和实验管理，旨在帮助数据科学团队使用Git将大型数据集和模型与代码一同进行版本管理。<sup>[1](https://doc.dvc.org/user-guide)</sup> 它于2017年5月4日公开发布，自2025年11月起，在项目从Iterative.ai被收购后，由lakeFS（Treeverse）接管维护。<sup>[2](https://mcislab.github.io/publications/2021/saner.pdf)</sup><sup> • </sup><sup>[3](https://dvc.org/blog/dvc-joins-lakefs-your-questions-answered/)</sup>

| 关键事实 | 详情 |
|---|---|
| 是什么 | 用于数据版本管理、机器学习流水线自动化和实验管理的开源工具，专为与Git及现有工程工具链配合而构建<sup>[1](https://doc.dvc.org/user-guide)</sup> |
| 首次发布 | 2017年5月4日公开发布<sup>[2](https://mcislab.github.io/publications/2021/saner.pdf)</sup> |
| 版本管理模型 | 小型的`.dvc`和`dvc.yaml`元文件作为占位符提交到Git；实际数据存放在Git之外的DVC缓存中，以内容哈希为键<sup>[1](https://doc.dvc.org/user-guide)</sup><sup> • </sup><sup>[2](https://mcislab.github.io/publications/2021/saner.pdf)</sup> |
| 远程存储 | S3及S3兼容存储、Azure Blob Storage、Google Cloud Storage、Google Drive、阿里云OSS、SSH/SFTP、HDFS、HTTP、WebDAV以及本地目录<sup>[4](https://doc.dvc.org/user-guide/data-management/remote-storage)</sup> |
| 平台范围 | 可在Linux、macOS和Windows上运行，且独立于编程语言（Python、R、Julia、shell脚本）和机器学习库<sup>[1](https://doc.dvc.org/user-guide)</sup> |
| 维护归属 | 由lakeFS（Treeverse Labs）从Iterative.ai收购，于2025年11月18日宣布；DVC继续作为独立开源工具存在<sup>[3](https://dvc.org/blog/dvc-joins-lakefs-your-questions-answered/)</sup><sup> • </sup><sup>[5](https://www.prnewswire.com/news-releases/lakefs-acquires-dvc-uniting-data-version-control-pioneers-to-accelerate-ai-ready-data-302618339.html)</sup> |

## 版本管理的工作方式

DVC在Git之上增加了数据版本管理：不应存储在Git仓库中的大文件仍然可以被跟踪和版本化，而Git则负责代码、配置、参数和指标。当使用`dvc add`跟踪一个文件或目录时，DVC会写入一个小的文本占位文件（`.dvc`文件），其中包含数据的MD5哈希及其存储位置的URI；数据本身则移入DVC缓存。将占位文件提交到Git即可记录数据版本，而无需将数据存入Git。<sup>[1](https://doc.dvc.org/user-guide)</sup><sup> • </sup><sup>[2](https://mcislab.github.io/publications/2021/saner.pdf)</sup>

存储采用内容寻址，因此相同的文件会被去重：如果某个文件在新版本中未发生变化，其哈希相同，DVC会复用已有的缓存副本，而不是再次存储。<sup>[6](https://discuss.dvc.org/t/redundant-data-across-version-and-within-versions/60)</sup> 为避免工作区和缓存在磁盘上重复存储数据，DVC会将缓存文件链接到工作区，优先使用reflink（写时复制链接，前提是文件系统支持），其次是硬链接或符号链接，最后退回到普通复制——这种方式安全，但对数GB及以上的文件效率较低。<sup>[7](https://doc.dvc.org/user-guide/data-management/large-dataset-optimization)</sup>

## 远程存储与协作

DVC远程是用于缓存数据和模型的外部存储位置，类似于Git远程，但针对的是数据。支持的后端包括[Amazon S3](https://www.edgepedia.org/zh/amazon-s3)及S3兼容服务（如MinIO）、Azure Blob Storage、Google Cloud Storage、Google Drive、阿里云OSS、SSH和SFTP、HDFS和WebHDFS、HTTP、WebDAV，以及普通的本地或网络目录。`dvc push`将当前提交的缓存数据上传到配置的远程，`dvc pull`则将其下载，因此协作者可以克隆Git仓库并复现完全相同的数据状态。<sup>[4](https://doc.dvc.org/user-guide/data-management/remote-storage)</sup><sup> • </sup><sup>[8](https://datos.gob.es/sites/default/files/documentacion/files/Guia_DVC_en.pdf)</sup>

凭据等敏感设置通过`--local`标志写入被Git忽略的文件`.dvc/config.local`，因此机密信息不会被提交；仓库的每个副本都需要重新配置这些值。<sup>[4](https://doc.dvc.org/user-guide/data-management/remote-storage)</sup> 由于远程配置本身保存在Git中，包含DVC元文件的Git仓库就成为一个入口，可以从中定位并下载任何版本的数据集或模型，例如使用`dvc get`。<sup>[9](https://doc.dvc.org/user-guide/data-management/discovering-and-accessing-data)</sup>

## 流水线与实验

除了文件版本管理，DVC还将机器学习流水线定义为`dvc.yaml`文件中的阶段图，每个阶段声明一条命令、其依赖项及其输出。运行`dvc repro`只会重新执行依赖项发生变化的阶段。DVC还可以跟踪存储在YAML、JSON和CSV等结构化文件中的参数、指标和图表。<sup>[10](https://doc.dvc.org/user-guide/pipelines/defining-pipelines)</sup><sup> • </sup><sup>[11](https://doc.dvc.org/user-guide/experiment-management)</sup> 1.0版本引入了通过`dvc plots diff`和`dvc plots show`进行指标可视化的功能。<sup>[12](https://dvc.org/blog/dvc-1-0-release/)</sup>

实验与Git仓库绑定，但会被`git push`和`git clone`等常规Git操作忽略。`dvc exp`命令用于运行、排队、比较和共享实验；`dvc exp push`上传实验的指标、图表、代码和缓存数据，以便从Git仓库复现，并可选择将实时指标和图表流式传输到DVC Studio。<sup>[11](https://doc.dvc.org/user-guide/experiment-management)</sup><sup> • </sup><sup>[13](https://doc.dvc.org/user-guide/experiment-management/sharing-experiments)</sup>

## 与相关工具的比较

**Git-LFS。** 与Git-LFS不同，DVC不需要专用服务器：任何云存储甚至SSH服务器都可以作为远程，无需额外的数据库或基础设施。Git-LFS并非为数据科学工作流而构建，缺少机器学习流水线和指标跟踪等功能；GitHub的Git托管对每个仓库施加2 GB的限制。<sup>[1](https://doc.dvc.org/user-guide)</sup> 一项比较性学术评估发现，DVC满足的研究数据版本管理需求最多，同时指出Git-LFS通过其紧密的Git集成提供了更顺畅的用户体验。<sup>[14](https://publikationen.bibliothek.kit.edu/1000177203/155972411)</sup>

**lakeFS。** DVC侧重于Git仓库内轻量级的、基于文件的版本管理，而lakeFS则作为集中式对象存储之上的控制平面运行，在PB级数据上提供分支、提交和回滚，且无需数据复制。DVC自己的文档建议，对于以数据湖为中心或经常同步数万个及以上文件的工作流，可以使用lakeFS。<sup>[1](https://doc.dvc.org/user-guide)</sup><sup> • </sup><sup>[4](https://doc.dvc.org/user-guide/data-management/remote-storage)</sup> 2025年11月，两个项目走向融合：lakeFS收购了DVC并接管了维护和活跃开发，DVC继续作为开源工具，专注于使用较小数据集的数据科学家，而lakeFS则面向企业级基础设施。<sup>[3](https://dvc.org/blog/dvc-joins-lakefs-your-questions-answered/)</sup><sup> • </sup><sup>[5](https://www.prnewswire.com/news-releases/lakefs-acquires-dvc-uniting-data-version-control-pioneers-to-accelerate-ai-ready-data-302618339.html)</sup>

## 局限性

处理大量小文件时的性能也是一个反复出现的问题，因为DVC历史上会为每个文件重新建立与远程的连接，不过维护者已经发布了针对此问题的优化。<sup>[15](https://discuss.dvc.org/t/advice-for-versioning-many-many-small-files/609)</sup> 在Windows上，NTFS的特性、影响基于内容的校验和的换行符差异以及路径长度限制，都需要特定配置才能可靠运行。<sup>[16](https://doc.dvc.org/user-guide/how-to/run-dvc-on-windows)</sup>

## 生态系统与采用情况

Iterative的DVC团队还发布了相关的开源项目，包括CML（Continuous Machine Learning，持续机器学习），一个用于在[GitHub Actions](https://www.edgepedia.org/zh/github-actions)和GitLab CI上运行机器学习项目CI/CD的库，以及DVCLive。<sup>[17](https://dvc.org/blog/cml-release/)</sup><sup> • </sup><sup>[3](https://dvc.org/blog/dvc-joins-lakefs-your-questions-answered/)</sup> 2021年一项针对GitHub上DVC项目的实证研究发现，该工具的核心功能在391个被研究的项目中有321个被采用，表明大多数公开的DVC仓库用它将数据和模型与代码一同进行版本管理。<sup>[2](https://mcislab.github.io/publications/2021/saner.pdf)</sup>

## References

1. [What is DVC? – DVC User Guide](https://doc.dvc.org/user-guide)
2. [Barrak, Eghan, Adams (SANER 2021). On the Co-evolution of ML Pipelines and Source Code – Empirical Study of DVC Projects](https://mcislab.github.io/publications/2021/saner.pdf)
3. [DVC Joins lakeFS: Your Questions Answered! – DVC Blog, November 18, 2025](https://dvc.org/blog/dvc-joins-lakefs-your-questions-answered/)
4. [Remote Storage – DVC User Guide](https://doc.dvc.org/user-guide/data-management/remote-storage)
5. [lakeFS Acquires DVC – PR Newswire, November 18, 2025](https://www.prnewswire.com/news-releases/lakefs-acquires-dvc-uniting-data-version-control-pioneers-to-accelerate-ai-ready-data-302618339.html)
6. [Redundant Data across versions – DVC Community Forum](https://discuss.dvc.org/t/redundant-data-across-version-and-within-versions/60)
7. [Large Dataset Optimization – DVC User Guide](https://doc.dvc.org/user-guide/data-management/large-dataset-optimization)
8. [Technical guide: Data version control – datos.gob.es](https://datos.gob.es/sites/default/files/documentacion/files/Guia_DVC_en.pdf)
9. [Discovering and Accessing Data – DVC User Guide](https://doc.dvc.org/user-guide/data-management/discovering-and-accessing-data)
10. [Defining Pipelines – DVC User Guide](https://doc.dvc.org/user-guide/pipelines/defining-pipelines)
11. [Experiment Management – DVC User Guide](https://doc.dvc.org/user-guide/experiment-management)
12. [DVC 1.0 release: new features for MLOps – DVC Blog](https://dvc.org/blog/dvc-1-0-release/)
13. [Sharing Experiments – DVC User Guide](https://doc.dvc.org/user-guide/experiment-management/sharing-experiments)
14. [Tools for Managing Research Data – INFORMATIK 2024 (KIT publication)](https://publikationen.bibliothek.kit.edu/1000177203/155972411)
15. [Advice for versioning many many small files? – DVC Community Forum](https://discuss.dvc.org/t/advice-for-versioning-many-many-small-files/609)
16. [How to Run DVC on Windows – DVC User Guide](https://doc.dvc.org/user-guide/how-to/run-dvc-on-windows)
17. [New Release: Continuous Machine Learning (CML) is CI/CD for ML – DVC Blog](https://dvc.org/blog/cml-release/)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Free and open-source software

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/dvc-data-version-control

English original: https://www.edgepedia.org/dvc-data-version-control
