← Blog
An open lavender archive drawer with an orange index tab.
Published on
2026-11-25

Use DVC and S3 to recover the dataset behind a Git commit

A training run used ticket 102 as an example of an order. A week later, someone corrected its category to refund. The filename stayed the same. If you rerun the original experiment, which row will you get?

With Data Version Control (DVC), you can answer that question with a Git commit and access to an S3 remote. Git records the small tickets.csv.dvc file that identifies the data. The remote holds the contents. To recover the dataset, check out the commit and run dvc pull. The handoff works only if someone uploaded that version while they still had it.

Choose what the team will share

Start in a new project directory with Git, Python and an existing bucket. The examples use PowerShell and the DVC versions we tested. Replace the example bucket and prefix with your own. Give the writer credentials that can upload objects and the reader credentials that can list and read the project’s objects.

python -m pip install "dvc==3.66.1" "dvc-s3==3.2.2"
git init
dvc init
dvc remote add -d datasets s3://dataset-handoff/dvc-cache

This saves the default remote in .dvc/config, which belongs in Git. For a provider with a custom S3 endpoint, set DVC_S3_ENDPOINT in your shell to the provider’s HTTPS endpoint and run the next command. On standard Amazon S3 you can omit this step.

dvc remote modify --local datasets endpointurl "$env:DVC_S3_ENDPOINT"

The local setting stays in .dvc/config.local. Every fresh clone needs the custom endpoint again. Supply credentials through a role or a local AWS profile appropriate to the environment. Keep secrets out of Git. DVC’s S3 configuration guide covers endpoint, profile and region settings.

Record and upload each dataset revision

Put your first dataset in tickets.csv. The commands below record its pointer in Git, upload the data and print two values worth saving together in the experiment record: the Git revision and the SHA-256 digest of the source file.

dvc add tickets.csv
git add .dvc .dvcignore .gitignore tickets.csv.dvc
git commit -m "Track ticket categories"
dvc push
git rev-parse HEAD
Get-FileHash tickets.csv -Algorithm SHA256

After correcting the CSV, repeat the sequence with a descriptive commit message. If collaborators use a hosted Git repository, push the commits to that repository as well. A Git push transfers the pointer history. A DVC push sends the corresponding data from the writer’s cache to the configured remote. A teammate needs access to both.

Recover the file from a clean clone

Set DATA_REPO to the Git repository URL and DATA_REVISION to the commit recorded for the experiment. Use a fresh directory and an empty DVC cache. A shared cache can make a recovery appear to work even when the object is missing from the remote. The example includes the custom endpoint line. Skip it when using standard Amazon S3.

git clone "$env:DATA_REPO" reader
Set-Location reader
git switch --detach "$env:DATA_REVISION"
dvc remote modify --local datasets endpointurl "$env:DVC_S3_ENDPOINT"
dvc pull tickets.csv.dvc
Get-FileHash tickets.csv -Algorithm SHA256

Compare the digest with the one saved by the writer for that commit. DVC pull downloads the required data into the cache and materializes the tracked file in the working directory. Git can tell you which version you asked for even if the file itself is unavailable.

What happened when we skipped a push

We tested two 41-byte CSVs with separate Git clones and independently empty caches. Both files had the same name, row count and byte count. Changing ticket 102 from orders to refund was enough to produce a different digest.

  • Original revision. The recovered SHA-256 began 734c3ccc0643 and matched the full source digest.
  • Corrected revision, before upload. Git checked out the commit. DVC exited with code 1 and the CSV was absent.
  • Corrected revision, after upload. The writer ran dvc push. The reader pulled again at the same commit and recovered the corrected file. Its SHA-256 began e2ab15042327 and matched the source.

If a pull fails, first check the commit, remote, endpoint and reader permissions. If those are right, ask someone who still has the required version in their DVC cache to push it. A bucket lifecycle rule that expires historical objects can break an old experiment even while the newest one still runs.

Evaluate a remote with a real handoff

We used Moto’s local S3 emulator on one Windows machine. To evaluate Object Storage with Hivenet, repeat the two-revision check in a disposable bucket with separate writer and reader credentials. For a plain directory transfer, see how AWS S3 sync handles changed files. If you also need to recover overwritten objects by key, review how S3 Versioning works alongside your retention settings.

Your next workload belongs on Hivenet.

Pick one AI, compute, or storage workload and see the difference for yourself. Spin it up in minutes, or let our team map your fastest path to production.