LinuxCommandLibrary

dolt-fetch

Download objects and refs from another repository

TLDR

Fetch the latest changes from the default remote upstream repository (origin)

$ dolt fetch
copy

Fetch latest changes from a specific remote upstream repository
$ dolt fetch [remote_name]
copy

Update branches with the current state of the remote, overwriting any conflicting history
$ dolt fetch -f
copy

SYNOPSIS

dolt fetch [options] [remote] [refspec…]

PARAMETERS

--all
    Fetch from all remotes

-p, --prune
    Prune remote-tracking branches no longer on remote

-t, --tags
    Fetch all tags from remote(s)

--no-tags
    Do not fetch tags

--dry-run
    Show what would be fetched without doing it

-q, --quiet
    Suppress progress reporting

--depth
    Shallow fetch limited to n commits from tip

--prune-tags
    Prune local tags no longer on remote

DESCRIPTION

The dolt fetch command retrieves commits, refs, tags, and database objects from a remote Dolt repository into your local Dolt database, mirroring git fetch functionality. Dolt is a version-controlled SQL database that treats data like code in Git, so dolt fetch updates remote-tracking branches (e.g., origin/main) without merging changes into your working branches. This allows safe review of incoming changes before integration via dolt merge or dolt pull.

It supports fetching from specific remotes, all remotes, or custom refspecs to pull specific branches or tags. Options like pruning remove stale remote refs, while shallow fetches limit history depth for efficiency. Unlike Git, Dolt fetches include both schema alterations and table data versions, enabling SQL-based diffs and conflicts resolution.

Usage typically follows initializing a Dolt repo with dolt init, adding a remote via dolt remote add, then fetching updates. It's essential for collaborative workflows on DoltHub or private remotes, ensuring your local clone stays synchronized with upstream without altering your working state.

CAVEATS

Requires Dolt installed; works only on Dolt databases, not plain Git repos. Fetches can be large due to data tables; use --dry-run first on big repos.

COMMON USAGE

dolt fetch origin fetches from default remote.
dolt fetch --all -p updates all remotes and prunes stale refs.

REFSPEC EXAMPLE

dolt fetch origin main:local-main fetches origin/main into local local-main branch.

HISTORY

Introduced with Dolt v0.20.0 in 2020 by DoltHub team. Evolved alongside Git compatibility improvements; current v1.20+ (2023) adds better shallow fetch and refspec support for enterprise data versioning.

SEE ALSO

dolt-pull(1), dolt-push(1), dolt-remote(1), git-fetch(1)

Copied to clipboard