LinuxCommandLibrary

dvc-init

Initialize DVC repository in a project

TLDR

Initialize a new local repository

$ dvc init
copy

Initialize DVC without Git
$ dvc init --no-scm
copy

Initialize DVC in a subdirectory
$ cd [path/to/subdirectory] && dvc init --sudir
copy

SYNOPSIS

dvc init [OPTIONS]

PARAMETERS

--cd DIR
    Change to DIR before running init.

--force, -f
    Force re-initialization if DVC already exists.

--no-scm
    Skip all Git checks and initialization.

--quiet, -q
    Suppress non-error output.

--subdir
    Recursively init DVC in all Git submodules/subdirs.

--template NAME
    Use a named template for initialization.

-v, -V, --verbose
    Enable verbose output.

-h, --help
    Show command help and exit.

DESCRIPTION

The dvc init command sets up a new DVC (Data Version Control) repository, enabling version control for data, models, and ML pipelines alongside Git for code. It creates essential directories and files: a .dvc/ folder for object cache, lockfiles, and tmp storage; .dvc/config for project settings like cache type and remote storage; and updates .gitignore to exclude DVC cache.

If no Git repo exists, it runs git init automatically (skippable with --no-scm). This integrates DVC seamlessly with Git, allowing .dvc files (pointers to data) to be committed while large files stay out of Git.

Ideal for data science projects, it supports reproducible experiments, team collaboration, and CI/CD. Post-init, use dvc add for data tracking, dvc repro for pipelines. Reinitializing requires --force. Supports templates for quick starts with pre-configured remotes or experiments.

CAVEATS

Fails if DVC already initialized without --force. Requires Git for full functionality (use --no-scm to bypass). Not for monorepos without --subdir. Cache dir must be writable.

HISTORY

Core command since DVC v0.1 (July 2017) by Iterative.ai. Gained --subdir in v1.0 (2019) for monorepos; templates in v2.0+ (2021). Evolved with cloud remotes and experiments support.

SEE ALSO

dvc(1), git-init(1), dvc-add(1), dvc-config(1)

Copied to clipboard