Sub topic 5
Sharing Data Through a Remote
This chapter assumes you know basic Git commands, can use a terminal, and have already run dvc init and dvc add. A DVC remote is a shared location for the actual contents of tracked files. Git stores the small .dvc pointer files, while the remote stores the larger data and model files.
Why a Remote Is Needed
DVC keeps file contents in a local cache. This cache lets DVC restore a file without copying it from Git. However, a local cache does not help a teammate or a continuous integration (CI) machine. Each user needs access to a shared remote.
A remote can use several storage systems:
| Remote type | Example | Common use |
|---|---|---|
| Amazon S3 | `s3://ml-team/dvc-store` | Cloud-based team storage |
| Google Cloud Storage | `gs://ml-team/dvc-store` | Google Cloud projects |
| Local or network path | `/shared/dvc-store` | Private networks and tests |
The remote should be separate from the Git repository when the files are large. It should also have access controls, backups, and a retention policy appropriate for the project.
Configuring the Remote
Create a remote with dvc remote add. The -d option makes it the default remote for this project.
dvc remote add -d storage s3://my-bucket/dvc-store
git add .dvc/config
git commit -m "Configure default DVC remote"This command writes the remote name and URL to .dvc/config. The configuration is normally safe to commit because it identifies storage but does not contain credentials.
DVC uses the cloud provider's standard credential mechanisms. For example, an AWS setup might use an IAM role, environment variables, or a local AWS profile. Do not put access keys in .dvc/config, shell history, or source code.
Uploading and Downloading Files
After adding a file, dvc push uploads the cached content that the current Git-tracked pointer files reference.
dvc pushA teammate first clones the Git repository. The clone contains the pointer files but not the large data files. The teammate then runs:
git clone https://example.com/team/project.git
cd project
dvc pulldvc pull reads the pointer files, finds the required objects in the configured remote, and places them in the local DVC cache and workspace.
The relationship looks like this:
DVC transfers content by its hash. If an object already exists in the remote, DVC does not upload it again. This makes repeated pushes efficient and allows different projects or revisions to reuse identical content.
Common Remote Problems
A successful Git checkout does not prove that the data is available. A later dvc pull can fail because:
- The remote URL is wrong or the bucket does not exist.
- Credentials are missing or expired.
- The current user lacks read or write permission.
- A pointer file refers to content that was never pushed.
- Network or provider limits interrupt the transfer.
Use dvc remote list to inspect configured remotes. Use dvc status to identify workspace changes, and read the full error message before changing configuration.
Exercise
A teammate cloned the repository successfully but cannot open data/raw.csv. What command should they try, and what must be true for it to work?
Show answer
They should run dvc pull. The repository must contain the correct pointer file, the configured remote must contain its referenced object, and the teammate must have permission to read that remote.