Description
Thedvc init command initializes a DVC repository in a directory, creating the necessary DVC structure (.dvc directory and configuration files). This is typically the first command you run when starting to use DVC in a project.
Usage
Arguments
Directory to initialize DVC in. Defaults to the current working directory.
Options
Initiate DVC in directory that is not tracked by any SCM tool (e.g. Git).By default, DVC expects to be initialized in a Git repository. Use this flag to use DVC without Git.
Overwrite existing
.dvc/ directory. This operation removes local cache.Necessary for running this command inside a subdirectory of a parent SCM repository.Allows you to initialize a DVC project in a subdirectory of a Git repository (monorepo structure).
Examples
Initialize in Current Directory
dvc init creates a .dvc directory with configuration files and adds them to .gitignore.Initialize Without Git (Standalone)
- You’re using a different version control system
- You want to use DVC for data management without version control
- You’re in an environment where Git isn’t available
Reinitialize (Force)
Initialize in Subdirectory (Monorepo)
- Monorepo projects with multiple sub-projects
- Large repositories where only part needs DVC tracking
- Separate data management for different components
What Gets Created
When you rundvc init, DVC creates the following structure:
.gitignore:
.gitignore
Post-Initialization Steps
Initialization Checks
Before initializing, verify:Git is initialized
Git is initialized
--no-scm)Directory is correct
Directory is correct
No existing .dvc directory
No existing .dvc directory
--force if you need to reinitialize.Use Cases
New ML Project
Start tracking datasets, models, and experiments from day one.
Existing Project
Add data version control to an existing codebase.
Monorepo Setup
Use
--subdir to enable DVC in part of a larger repository.No-Git Workflow
Use
--no-scm for DVC-only data management without version control.Configuration After Init
After initialization, you may want to configure:Cache Location
Analytics (Opt-out)
Autostage
Troubleshooting
Already Initialized Error
dvc init --force to reinitialize (note: this removes local cache).
Not a Git Repository Error
git init first, or use dvc init --no-scm.
Permission Denied
Related Commands
dvc add- Start tracking data files with DVCdvc remote add- Configure remote storagedvc config- Modify DVC configurationdvc destroy- Remove DVC from project (opposite of init)