How do I remove files which are no longer tracked by DVC from DVC remote SSH storage


I had added a folder inputs to remote ssh dvc storage.
After some time, i decided to remove this folder
so i did

  • dvc remove inputs.dvc
  • did a git commit and push of the dvc changes
    But if i use an older commit where the inputs folder was tracked by dvc i am still able to pull inputs folder from remote dvc storage

How can i remove the file from the remote ssh dvc storage?

Hi @shaijujanardhanan !

We have a dvc gc command that does precisely that. For example, if you want to remove all cache that is not used in any of your git tags and branches on your default remote, you could do dvc gc -caT. See for more info.


Thanks @kupruser for the info

1 Like

Do I understand correctly that this should remove the files from the dvc repository itself? That is, the hash-named folders and files?

I’ve been testing dvc with a local remote (and without git, that is, --no-scm) and was studying how to manage the repository itself. How does one remove files from the repository? What if a user accidentally adds a file they don’t want in the repository (similar to pushing a file accidentally into git)?

The gc command doesn’t seem to work as I anticipated. It issues an error “‘NoSCM’ object has no attribute ‘resolve_rev’”.

I’m assuming this is a special case (my non-git associated test dvc repository with --no-scm). Would remove/gc otherwise be the proper approach to removing something from a proper git-associated repository?


1 Like

I was able to get around the error message by running git init first on a new directory, then setting up dvc on that directory, deleting the *.dvc files, and running dvc gc on the local cache and local remote.

That finally removed the copies of the files from the repository itself.

@HDBits it looks like a bug that GC does not work with --no-scm? Could you create a ticket on Github, please?

I went back and tried to duplicate my result, but could not.

I couldn’t find the original tutorial that I used to practice with DVC, so I tried a number of different simple cases, none of which produced the error I was originally seeing.

Recall that I was running dvc init with the --no-scm option.

dvd gc was behaving as expected, removing files from the local folder .dvc as well as the local remote (when used with -c).