How to Initialize DVC in a Git Repository with dvc init
dvc init turns a Git repository into a DVC project. It adds a .dvc folder for DVC's settings and its cache, and a .dvcignore file, and stages them in Git for you. This guide runs it in a small repository, looks at each file it made, commits them, and explains the two errors you're likely to meet, with DVC 3.67.1.
Syntax
dvc init
Run it in the top folder of a Git repository: the folder that holds .git. The dvc init reference says the command "(without flags) expects to run in a Git repository root (a .git/ directory should be present)."
The Example
recipes is a Git repository with one commit, a README.md. It will hold recipe photos later, which are too big for Git, so it gets DVC first.
Prerequisites
- DVC. Run
dvc --versionto check; this guide uses DVC 3.67.1.
Step 1: Run dvc init
In the repository's top folder:
dvc init
Initialized DVC repository.
You can now commit the changes to git.
What's next?
------------
- Check out the documentation: <https://dvc.org/doc>
- Get help and share ideas: <https://dvc.org/chat>
- Star us on GitHub: <https://github.com/treeverse/dvc>

If DVC's usage analytics are on, a red box about them comes first. This run had them off.
Step 2: See What It Changed
git status --short
A .dvc/.gitignore
A .dvc/config
A .dvcignore

A in the first column means the file is already staged: the reference says the .dvc folder "is automatically staged with git add, so it can be easily committed with Git." Here's what each file is:
| File | What it's for |
|---|---|
.dvc/config | DVC's settings for this project, empty for now. The internal files page calls it "the default DVC configuration file" |
.dvc/.gitignore | Keeps DVC's own private files out of Git |
.dvcignore | Patterns for files DVC should skip, like .gitignore for Git |
Step 3: Look Inside the .dvc Folder
- bash / zsh
- PowerShell
ls -a .dvc
. .. .gitignore config tmp
Get-ChildItem -Force -Name .dvc
tmp
.gitignore
config
cat .dvc/.gitignore
/config.local
/tmp
/cache

PowerShell lists the same three entries, one per line, and cat works there too. .dvc/.gitignore keeps three things out of Git:
/config.local: a settings file for values that must stay on your computer, such as passwords. It doesn't exist until you use it./tmp: DVC's temporary files./cache: the cache, where DVC keeps a copy of every version of your data. It appears the first time you track a file.
.dvcignore holds only comments for now:
# Add patterns of files dvc should ignore, which could improve
# the performance. Learn more at
# https://dvc.org/doc/user-guide/dvcignore
Step 4: Commit the DVC Files
The files are staged, so commit them:
git commit -m "Initialize DVC"
[main 5651922] Initialize DVC
3 files changed, 6 insertions(+)
create mode 100644 .dvc/.gitignore
create mode 100644 .dvc/config
create mode 100644 .dvcignore

Now everyone who clones the repository gets a DVC project. The command works unchanged in PowerShell.
Error: '.dvc' exists
Running dvc init a second time stops:
ERROR: failed to initiate DVC - '.dvc' exists. Use `-f` to force.
The project is already initialized, so there's nothing to do. Don't reach for -f: the reference says it will "remove .dvc/ if it exists before initialization. Will remove any existing local cache."
Error: Not Tracked by Any Supported SCM Tool
In a folder that isn't a Git repository, dvc init stops with this:
ERROR: failed to initiate DVC - /Users/you/source/no-git-folder is not tracked by any supported SCM tool (e.g. Git). Use `--no-scm` if you don't want to use any SCM or `--subdir` if initializing inside a subdirectory of a parent SCM repository.
SCM means source control, such as Git. The same error appears in a subfolder of a Git repository, here recipes/notes, because dvc init wants the repository's top folder:
ERROR: failed to initiate DVC - /Users/you/source/recipes/notes is not tracked by any supported SCM tool (e.g. Git). Use `--no-scm` if you don't want to use any SCM or `--subdir` if initializing inside a subdirectory of a parent SCM repository.
Run git init first, or move to the top folder. The two options in the message are for special setups: --no-scm for a project without Git, and --subdir for several DVC projects inside one Git repository.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Running dvc init before git init | is not tracked by any supported SCM tool (e.g. Git) | Run git init first |
| Running it in a subfolder of the repository | The same error | Move to the folder that holds .git |
| Not committing the new files | People who clone the repository don't get the DVC project | git commit after dvc init |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
failed to initiate DVC - '.dvc' exists | DVC is already set up here | Nothing to do; carry on with dvc add |
is not tracked by any supported SCM tool (e.g. Git) | No Git repository in this folder | git init, or run it in the repository's top folder |
FAQ
Do I need Git to use DVC?
DVC works without it, through dvc init --no-scm, but the reference says it "works best in a Git repository", because Git is what keeps track of each version of your data.
Where is the cache?
In .dvc/cache, once you track your first file. .dvc/.gitignore already keeps it out of Git.
Conclusion
dvc init created .dvc/config, .dvc/.gitignore and .dvcignore, staged them, and one commit made the repository a DVC project. Its two errors mean the project is already set up, or the folder isn't the top of a Git repository.
Additional Resources
- dvc init — every option, including
--subdirand--no-scm. - Internal files — what each file in
.dvcis for.
