Initialize DVC and Track a Dataset
Run dvc add and commit the pointer, not the data.
Initialize DVC and Track a Dataset is a free MLOps Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MLOps Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Install DVC First
DVC is a Python package, so a single pip command gets you started. After this you have the dvc command available in your terminal.
pip install dvcStart Inside a Git Repo
DVC works alongside Git, not instead of it. So you run it inside an existing Git repository where your code already lives.
git init
dvc initWhat dvc init Creates
dvc init adds a hidden .dvc folder holding config and the local cache. Commit it once so the whole team shares the same setup.
git add .dvc .dvcignore
git commit -m "Initialize DVC"Track Your First Dataset
Point DVC at the file or folder you want versioned with dvc add. DVC moves the real data into its cache and leaves a small placeholder behind.
dvc add data/train.csvThe .dvc Pointer File
dvc add creates a tiny .dvc file next to your data. It stores the file's hash and size, acting as the address Git will track.
# data/train.csv.dvc
outs:
- md5: 3f2a9c...
size: 524288
path: train.csvGit Tracks the Pointer
You commit the small .dvc file to Git, never the raw dataset. Git now records which version of the data this commit expects.
git add data/train.csv.dvc
git commit -m "Track training data"Real Data Goes to .gitignore
So you never commit the big file by accident, dvc add auto-adds the dataset path to .gitignore. Git simply ignores the heavy bytes.
cat .gitignore
# /train.csvContent-Addressable Cache
DVC names cached files by their content hash. Identical data is stored once, so duplicate datasets never waste disk space. 💾
Check the Status
Run dvc status any time to see whether your working data matches what the .dvc files expect. It is your quick health check.
dvc statusUpdate a Tracked File
When the dataset changes, just run dvc add again. DVC recomputes the hash and updates the .dvc file, which you commit as a new version.
dvc add data/train.csv
git add data/train.csv.dvc
git commit -m "New data snapshot"Track Folders Too
dvc add works on whole directories, not just single files. Point it at a folder and DVC versions everything inside as one tracked unit.
dvc add data/images/Quick Check
After running dvc add on a dataset, what do you commit to Git?
Recap
You ran dvc init, then dvc add to track a dataset. DVC caches the real data and writes a tiny .dvc pointer that Git commits, keeping code and data linked.
Frequently asked questions
Is the “Initialize DVC and Track a Dataset” lesson free?
Yes — the full text of “Initialize DVC and Track a Dataset” is free to read here on the web, and the MLOps Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MLOps Academy course, upgrade to CoddyKit PRO.
What will I learn in “Initialize DVC and Track a Dataset”?
Run dvc add and commit the pointer, not the data. You practise MLOps Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start MLOps Academy?
No prior experience is required. MLOps Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Initialize DVC and Track a Dataset” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this MLOps Academy lesson?
Yes. Every MLOps Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Why Git Alone Cannot Version Data
- Initialize DVC and Track a Dataset
- Push Data to Remote Storage
- Roll Back to an Earlier Dataset