Remove stages from dvc.yaml and/or stop tracking files or directories (and
optionally delete them).
usage: dvc remove [-h] [-q | -v] [--outs] targets [targets ...]
positional arguments:
targets stages (found in dvc.yaml) or .dvc files to remove.Safely removes .dvc files or stages from dvc.yaml. This includes deleting
the corresponding .gitignore entries (based on the outs fields removed).
dvc removedoesn't remove files from the DVC cache or remote storage. Usedvc gcfor that.
It takes one or more stage names (see -n option of dvc run) or .dvc file
names as targets.
If there are no stages left in dvc.yaml after the removal, then both
dvc.yaml and dvc.lock are deleted.
Note that the actual output files or directories of the stage
(outs field) are not removed by this command, unless the --outs option is
used.
π‘ Refer to Undo Adding Data to see how it helps replace data that is tracked by DVC.
--outs - remove the outputs of any targets as well.
β οΈThis option may be irreversible (e.g. if the data isn't cached).
-h, --help - prints the usage/help message, and exit.-q, --quiet - do not write anything to standard output. Exit with 0 if no
problems arise, otherwise 1.-v, --verbose - displays detailed tracing information.Let's imagine we have foo.csv and bar.csv files, that are already
tracked by DVC:
$ ls
bar.csv bar.csv.dvc foo.csv foo.csv.dvc
$ cat .gitignore
/foo.csv
/bar.csvThis removes foo.csv.dvc and double checks that its entry is gone from
.gitignore:
$ dvc remove foo.csv.dvc
$ ls
bar.csv bar.csv.dvc foo.csv
$ cat .gitignore
/bar.csvThe same procedure applies to tracked directories.
Let's imagine we have a train stage in dvc.yaml, and corresponding files in
the workspace:
train:
cmd: python train.py data.py
deps:
- data.csv
- train.py
outs:
- model$ ls
dvc.lock dvc.yaml foo.csv foo.csv.dvc model train.pyUsing dvc remove on the stage name will remove that entry from dvc.yaml, and
its outputs from .gitignore. With the --outs option, its outputs are also
deleted (just the model file in this example):
$ dvc remove train --outs
$ ls
dvc.lock dvc.yaml foo.csv foo.csv.dvc train.pyNotice that the dependencies (
data.csvandtrain.py) are not deleted.