Skip to main content

Description

The dvc destroy command removes all DVC-related files from your project, including the .dvc directory, configuration files, and local cache. This effectively uninitializes DVC from your repository.
This is a destructive operation that deletes your local cache. Make sure you’ve pushed important data to a remote storage before running this command.

Usage

dvc destroy [options]
dvc destroy

Arguments

This command takes no arguments.

Options

-f, --force
flag
Force destruction without asking for confirmation.By default, DVC asks for user confirmation before destroying the repository. Use this flag to skip the confirmation prompt (useful for automation).

What Gets Deleted

When you run dvc destroy, the following are permanently removed:
The entire .dvc directory, including:
  • Configuration files (.dvc/config, .dvc/config.local)
  • Local cache (.dvc/cache/)
  • Temporary files
  • Internal state files
All information about your data pipelines:
  • Stage definitions in dvc.yaml
  • Pipeline dependencies and outputs
  • Metrics and plots configurations
All cached data files:
  • Original versions of tracked files
  • Historical versions from previous commits
  • Cached pipeline outputs
Data in cache is permanently deleted. Ensure you’ve run dvc push to backup to remote before destroying.
What is NOT deleted:
  • .dvc files (e.g., data.csv.dvc) - These remain as regular files in your Git repository
  • Remote storage - Data in remote storage (S3, GCS, etc.) is unaffected
  • Git repository - Your Git history and tracked files remain intact

Examples

Destroy with Confirmation

$ dvc destroy
This will destroy all information about your pipelines, all data files,
as well as cache in .dvc/cache.

Are you sure you want to continue? [y/n] y

Successfully destroyed DVC repository.

Destroy Without Confirmation

$ dvc destroy --force
Successfully destroyed DVC repository.
Use --force in automated scripts or CI/CD pipelines where user interaction isn’t possible.

Before You Destroy

1

Backup to Remote

Ensure all important data is pushed to remote storage:
dvc push
2

Check Status

Verify no uncommitted changes:
dvc status
git status
3

Document Configuration

Save your DVC configuration if you might need it later:
dvc config --list > dvc-config-backup.txt
4

List Tracked Files

Document what files are tracked by DVC:
git ls-files '*.dvc' > dvc-tracked-files.txt

After Destruction

After running dvc destroy:

Project State

# .dvc directory is gone
ls .dvc
# ls: cannot access '.dvc': No such file or directory

# .dvc files remain but are now just regular files
ls *.dvc
# data.csv.dvc  model.pkl.dvc

Cleanup Git Repository

You may want to remove DVC-related files from Git:
# Remove .dvc files
git rm *.dvc

# Remove dvc.yaml and dvc.lock if present
git rm dvc.yaml dvc.lock

# Commit the changes
git commit -m "Remove DVC tracking"

Reinitialize DVC

If you want to start fresh:
# Reinitialize DVC
dvc init

# Reconfigure remote
dvc remote add -d storage s3://mybucket/dvc-storage

# Pull data from remote
dvc pull

Use Cases

Switch to Different Tool

Remove DVC when migrating to a different data versioning solution.

Clean Installation

Start fresh with a clean DVC setup after configuration issues.

Remove from Project

Permanently remove DVC from a project that no longer needs it.

Testing & Development

Quickly reset DVC state during testing or development.

Safety Checks

Dry Run Alternative

DVC destroy doesn’t have a dry-run option, but you can check what would be deleted:
# Check size of cache
du -sh .dvc/cache

# List all DVC files
find . -name "*.dvc"

# List cache contents
ls -lh .dvc/cache

Verify Remote Backup

Before destroying, verify your data is safely in remote storage:
# Check remote connection
dvc remote list

# Verify all data is pushed
dvc status --cloud

# Should show: "Cache and remote 'storage' are in sync."
If dvc status --cloud shows differences, some data hasn’t been pushed to remote and will be lost during destroy.

Comparison: destroy vs. remove

Featuredvc destroydvc remove
ScopeEntire DVC setupSpecific stage/file
Deletes cacheYes, entire cacheOnly related files
Deletes .dvc/YesNo
ReversibleNo (destructive)Partially
Removes from GitNoYes (with Git commit)

Recovery After Accidental Destroy

If you accidentally destroyed DVC:
1

Reinitialize DVC

dvc init
2

Restore Configuration

If you have a backup of your config:
# Restore remote configuration
dvc remote add -d storage s3://mybucket/dvc-storage
Or restore from Git history:
git show HEAD:.dvc/config > .dvc/config
3

Pull Data from Remote

dvc pull
This restores all cached data from remote storage.
4

Verify Status

dvc status
Should show everything is in sync.
As long as you have:
  1. .dvc files in Git
  2. dvc.yaml (if using pipelines)
  3. Data in remote storage
You can fully recover by reinitializing and running dvc pull.

Troubleshooting

Permission Denied

ERROR: Permission denied: '.dvc/cache'
Solution: Check file permissions or run with appropriate privileges:
sudo dvc destroy --force

Not a DVC Repository

ERROR: Not inside a DVC repository.
Solution: You’re not in a DVC-initialized directory. Either:
  • Navigate to the correct directory
  • DVC may already be destroyed

Files in Use

ERROR: Cannot remove '.dvc/cache': Resource busy
Solution: Close any programs accessing DVC cache files, then try again.

Automation Example

CI/CD Pipeline Cleanup

#!/bin/bash
# Cleanup script for CI/CD

set -e

echo "Backing up to remote..."
dvc push || true  # Continue even if push fails

echo "Destroying DVC repository..."
dvc destroy --force

echo "Removing DVC files from Git..."
git rm -rf *.dvc dvc.yaml dvc.lock 2>/dev/null || true

echo "Cleanup complete."
  • dvc init - Initialize DVC (opposite of destroy)
  • dvc push - Upload data to remote before destroying
  • dvc status --cloud - Check if data is backed up to remote
  • dvc remove - Remove specific DVC-tracked files (not entire setup)
  • dvc gc - Clean up cache without destroying DVC setup

Build docs developers (and LLMs) love