LinuxCommandLibrary

jj-git-fetch

Fetch Git remote changes

TLDR

Fetch the latest changes from the default remote repository

$ jj git fetch
copy

Fetch the latest changes from a given remote repository
$ jj git fetch --remote [remote]
copy

Fetch the latest changes only from given branches
$ jj git fetch [[-b|--branch]] [branch]
copy

Fetch the latest changes from all remotes
$ jj git fetch --all-remote
copy

SYNOPSIS

jj git fetch [options] [remote]

PARAMETERS

-a, --all
    Fetch from all configured remotes

--dry-run
    Print actions without performing fetch

-p, --prune
    Delete remote refs no longer present

--progress
    Show progress during fetch

remote
    Name of remote (defaults to 'origin')

DESCRIPTION

The jj git fetch command retrieves updates from one or more Git-compatible remote repositories and integrates them into the local jj repository's underlying Git backend. It downloads new objects, commits, tags, and branches without altering the working copy, commit graph, or working-copy state in jj. This enables seamless interoperability between jj and Git workflows.

By default, it fetches from the 'origin' remote if no remote is specified. Use --all to fetch from all configured remotes. After fetching, new remote changes appear in jj log with tracking refs like 'remote/origin/main'. Users can then review changes with jj show or incorporate them via jj rebase, jj merge, or jj new at a remote ref.

This command is essential for jj users collaborating in Git ecosystems, ensuring the repo stays synchronized with upstream changes. It supports Git's refspec syntax indirectly through config and handles automatic refspecs like '+refs/heads/*:refs/remotes/origin/*'. Fetching prunes stale refs with --prune to keep the repo clean. Unlike Git, jj fetch does not advance local branches automatically, preserving jj's explicit change model.

CAVEATS

Does not update jj working copy or local branches automatically; use jj rebase or similar. Requires Git backend initialized.

EXAMPLES

jj git fetch # Fetch from origin
jj git fetch --all -p # All remotes, prune stale refs
jj git fetch upstream # Specific remote

CONFIGURATION

Remotes configured via jj git remote or .git/config. Default refspecs from git config 'remote.<name>.fetch'.

HISTORY

Part of Jujutsu (jj), developed by Martin von Zweigbergk starting 2021 at Google. First stable release 2023; enhances Git UX while maintaining compatibility. git fetch support added early for hybrid workflows.

SEE ALSO

git-fetch(1), git(1), jj-git-push(1), jj-log(1)

Copied to clipboard