Skip to main content

How to Use a Local Folder as a DVC Remote

· 11 min read
Jagdish Kumawat
Founder @ Dewiride

A DVC remote is the storage that dvc push uploads your data to and dvc pull downloads it from. It doesn't have to be in the cloud: a folder on your own disk, a mounted drive or a network share works too, and costs nothing. This guide makes a folder in your home folder the default remote of a project with DVC 3.67.1, reads what DVC saved, and commits it.

Syntax​

Syntax
dvc remote add -d <name> <folder>
PartWhat it means
dvc remote addSaves a remote, a storage place for DVC's data, in the project's .dvc/config
-dShort for --default: makes it the remote that dvc push and dvc pull use when you don't name one
<name>A name you choose, such as storage. The reference says it "must be unique"
<folder>The folder that will hold the data, as an absolute path: the full path from the top of the disk

The dvc remote add reference says DVC remotes "can point to a cloud storage service, an SSH server, network-attached storage, or even a directory in the local file system."

The Example​

weather-data is a Git repository where dvc init has run and data/temperatures.csv is tracked with dvc add. Its data will go to a folder called dvc-storage in your home folder, outside the project.

Prerequisites​

  • DVC, in a Git repository where dvc init has run. Run dvc --version to check; this guide uses DVC 3.67.1.

Step 1: Add the Folder as the Default Remote​

In the project folder:

Terminal
dvc remote add -d storage $HOME/dvc-storage
Output
Setting 'storage' as a default remote.

The terminal after dvc remote add -d storage $HOME/dvc-storage, which prints Setting 'storage' as a default remote.

$HOME is your home folder, so on a Mac the remote is /Users/you/dvc-storage. PowerShell has a $HOME variable too: its documentation says that on Windows it's the USERPROFILE folder, "typically C:\Users\<UserName>". Join-Path adds the folder name to it with the right separator. The PowerShell line was checked in PowerShell 7.6 on macOS.

Step 2: See What DVC Saved​

Terminal
cat .dvc/config
.dvc/config
[core]
remote = storage
['remote "storage"']
url = /Users/you/dvc-storage

.dvc/config in a macOS-style code window: a core section with remote = storage, and a remote "storage" section with url = /Users/you/dvc-storage.

The command added two things:

  • ['remote "storage"'] is the remote itself: its name, and its url, the folder.
  • remote = storage in the [core] section is what -d added. It makes storage the default remote.

dvc remote list shows every remote of the project:

Terminal
dvc remote list
Output
storage /Users/you/dvc-storage (default)

The terminal after dvc remote list, which shows the remote storage, its folder /Users/you/dvc-storage, and the word default.

Both commands work unchanged in PowerShell.

Step 3: Check the Folder​

DVC saved the path, but it didn't create the folder:

Terminal
ls $HOME/dvc-storage
Output
ls: /Users/you/dvc-storage: No such file or directory

The terminal after ls $HOME/dvc-storage, which says No such file or directory.

That's expected. dvc push creates the folder the first time it uploads data.

Step 4: Commit the Setting​

.dvc/config is a file Git tracks, so the change shows up in Git:

Terminal
git status --short
Output
M .dvc/config

Commit it:

Terminal
git commit -am "Store DVC data in dvc-storage"
Output
[main 4b1c14f] Store DVC data in dvc-storage
1 file changed, 4 insertions(+)

The terminal after git status --short shows .dvc/config as modified, and git commit -am saves it as commit 4b1c14f with 4 insertions.

-a stages every changed file Git already tracks before it commits, here only .dvc/config. The remote is now part of the project, and every clone gets the same setting. Because the path is absolute, a clone on another computer can use it only where the same folder exists, such as a network drive mounted at the same path. The commands are the same in PowerShell.

A Relative Path Is Saved Differently​

The remote storage guide recommends an absolute path "because it's saved as-is in DVC config", and adds: "When using a relative path, it will be saved relative to the config file location, but resolved against the current working directory."

Here's what that means in weather-data-rel, a second copy of the example:

Terminal
dvc remote add -d storage ../dvc-storage
Output
Setting 'storage' as a default remote.
Terminal
cat .dvc/config
Output
[core]
remote = storage
['remote "storage"']
url = ../../dvc-storage
Terminal
dvc remote list
Output
storage /Users/you/source/dvc-storage (default)

The terminal after dvc remote add -d storage ../dvc-storage: .dvc/config saves the url as ../../dvc-storage, and dvc remote list shows the full path /Users/you/source/dvc-storage.

You typed ../dvc-storage, the folder next to the project. DVC saved ../../dvc-storage, with one ../ more, because it counts from .dvc/config, which sits one folder deeper, inside .dvc. Both point to the same folder, as dvc remote list shows. A relative path is useful when every copy of the project sits next to the storage folder, such as a project and its clones side by side in one folder: the path is right for all of them, and no user name ends up in a file Git shares.

Error: Remote Already Exists​

Running the same dvc remote add a second time fails:

Terminal
dvc remote add -d storage $HOME/dvc-storage
Output
Setting 'storage' as a default remote.
ERROR: configuration error - config file error: remote 'storage' already exists. Use `-f|--force` to overwrite it.

The terminal after running dvc remote add -d storage a second time: Setting 'storage' as a default remote, then the error remote 'storage' already exists.

Don't trust the first line: nothing was set, and .dvc/config still holds the first folder. I reported that line to the DVC project as treeverse/dvc#11161.

If the remote already points where you want, there's nothing to fix. To point it at another folder, add -f, which the reference describes as "overwrite existing remote with new url value":

Terminal
dvc remote add -d -f storage $HOME/dvc-storage-new
Output
Setting 'storage' as a default remote.
Terminal
dvc remote list
Output
storage /Users/you/dvc-storage-new (default)

The terminal after dvc remote add -d -f storage $HOME/dvc-storage-new and dvc remote list, which now shows the folder /Users/you/dvc-storage-new as the default.

Commit .dvc/config again after the change.

Error: No Remote Specified​

A remote added without -d isn't the default, so dvc push doesn't know where to upload. Here it happens in no-remote, another small project:

Terminal
dvc remote add storage $HOME/dvc-storage
dvc push
Output (last lines)
ERROR: failed to push data to the cloud - config file error: no remote specified in /Users/you/source/no-remote. Setup default remote with
dvc remote default <remote name>
or use:
dvc <command> -r <remote name>

The terminal after dvc remote add without -d and dvc push, which fails with no remote specified and suggests dvc remote default.

dvc remote add without -d prints nothing. The <command> in the last line is a placeholder DVC forgot to fill in: for dvc push, it means dvc push -r <remote name>. I reported it as treeverse/dvc#11163.

The first suggestion is the fix. dvc remote default makes an existing remote the default:

Terminal
dvc remote default storage
dvc remote list
Output
storage /Users/you/dvc-storage (default)

The terminal after dvc remote default storage, which prints nothing, and dvc remote list, which now marks storage as the default.

It adds the same remote = storage line to .dvc/config that -d adds. The other way is to name the remote in each command with -r, such as dvc push -r storage: the reference says commands use the default remote "unless their -r option is used".

Common Mistakes​

MistakeWhat happensDo this instead
Leaving out -ddvc push stops with no remote specifieddvc remote default <name>
Running dvc remote add twiceremote 'storage' already existsNothing, if the folder is right; -f to change it
Typing a relative path.dvc/config holds a different path from the one you typedUse an absolute path, which is saved as typed
Not committing .dvc/configClones of the project have no remotegit commit after dvc remote add

Troubleshooting​

SymptomLikely causeFix
remote 'storage' already existsA remote with that name is already in .dvc/configKeep it, or add -f to change its folder
no remote specified … Setup default remote withThe project has a remote, but none is the defaultdvc remote default <name>
no remote specified … Create a default remote withThe project has no remote at alldvc remote add -d <name> <folder>
No such file or directory for the remote's folderNothing has been pushed yetRun dvc push; it creates the folder

FAQ​

Can the remote be on a USB drive or a network share?​

Yes. The remote storage guide says: "You can also use system directories, mounted drives, network resources e.g. network-attached storage (NAS), and other external devices as storage." Give the drive's absolute path.

Can I keep the remote out of Git?​

Yes: --local saves it in .dvc/config.local instead. The reference calls that file "the Git-ignored local config file", "useful to save private remote config that you don't want to track and share with Git."

Does a local remote cost anything?​

No. It's a folder on your own disk, so the only cost is the space the data takes.

Conclusion​

dvc remote add -d storage $HOME/dvc-storage saved a folder in the home folder as the project's default remote, in two lines of .dvc/config, and one commit made it part of the project. The folder itself appears with the first dvc push. A relative path is saved relative to .dvc/config, a second remote add with the same name needs -f, and a remote added without -d needs dvc remote default.

Additional Resources​