Skip to content

Add --num option to dvc fetch #11033

Description

@ywilke

Problem
When merging two branches in a DVC repository it is possible to encounter missing cache data from previous commits. This results in errors such as:
ERROR: unexpected error - [Errno 2] No such file or directory: '~/my_repo/.dvc/cache/files/md5/xx/xxx.dir'

To resolve this, the current workaround is to run:
dvc fetch --all-commits
on both branches to ensure all required data is available locally. However, for long-lived branches like main, this can result in downloading a very large amount of data, much of which is not needed.

Proposed solution
Introduce a --num <N> option to dvc fetch, similar to the existing option in dvc gc, which limits operations to the most recent N commits.

Example:
dvc fetch --num 10
This would fetch cache data only for the latest 10 commits in the current branch, reducing unnecessary downloads.

I would be interested in contributing an implementation if this feature is considered useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions