diff --git a/content/docs/command-reference/add.md b/content/docs/command-reference/add.md index e2146257b1..128376b028 100644 --- a/content/docs/command-reference/add.md +++ b/content/docs/command-reference/add.md @@ -59,6 +59,9 @@ files that can be easily tracked with Git. It's possible to prevent files or directories from being added by DVC by adding the corresponding patterns in a [`.dvcignore`](/doc/user-guide/dvcignore) file. +You can also [undo `dvc add`](/docs/user-guide/how-to/undo-adding-data) to stop +tracking files or directories. + By default, DVC tries to use reflinks (see [File link types](/doc/user-guide/large-dataset-optimization#file-link-types-for-the-dvc-cache) to avoid copying any file contents and to optimize `.dvc` file operations for diff --git a/content/docs/sidebar.json b/content/docs/sidebar.json index de77dfde71..59cadea92a 100644 --- a/content/docs/sidebar.json +++ b/content/docs/sidebar.json @@ -98,7 +98,12 @@ "katacoda": "https://katacoda.com/dvc/courses/examples/dvcignore" } }, - "updating-tracked-files", + { + "label": "How To", + "slug": "how-to", + "source": false, + "children": ["undo-adding-data", "update-tracked-files"] + }, "setup-google-drive-remote", "large-dataset-optimization", "external-dependencies", diff --git a/content/docs/user-guide/how-to/undo-adding-data.md b/content/docs/user-guide/how-to/undo-adding-data.md new file mode 100644 index 0000000000..1d3935cad4 --- /dev/null +++ b/content/docs/user-guide/how-to/undo-adding-data.md @@ -0,0 +1,44 @@ +# Undo Adding Data + +There are situations where you want to stop tracking data added previously. +Follow the steps listed here to undo `dvc add`. + +Let's first add a data file into an example project using +`dvc add`, which creates a `.dvc` file to track the data: + +```dvc +$ dvc add data.csv +$ ls +data.csv data.csv.dvc +``` + +> Note, if you are using `symlink` or `hardlink` as +> [link type](doc/user-guide/large-dataset-optimization#file-link-types-for-the-dvc-cache) +> for DVC cache, you will have to unprotect the tracked file first +> (see `dvc unprotect`): +> +> ```dvc +> $ dvc unprotect data.csv +> ``` + +Now let's reverse `dvc add` by removing the corresponding `.dvc` file and +`.gitignore` entry using `dvc remove`: + +```dvc +$ dvc remove data.csv.dvc +``` + +Data file `data.csv` is now no longer being tracked by DVC. + +```dvc +$ git status + Untracked files: + data.csv +``` + +You can run `dvc gc` with the `-w` option to remove the data that isn't +referenced in the current workspace from the cache: + +```dvc +$ dvc gc -w +``` diff --git a/content/docs/user-guide/updating-tracked-files.md b/content/docs/user-guide/how-to/update-tracked-files.md similarity index 100% rename from content/docs/user-guide/updating-tracked-files.md rename to content/docs/user-guide/how-to/update-tracked-files.md