Files
holocron/plugins/git/skills/git-remotes/references/fetch.md
Defame1297 af8b46cd57 chore(plugins): sync generated content mirrors
Regenerate plugins/*/skills/ from plugins/*/.apm/ after the previous
four commits, via scripts/sync-plugin-content.sh --all. The mirror is
generated output (ADR-0017) that check-plugin-content-sync's pre-push
hook diffs against .apm/; nothing here is hand-edited.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EeH8SCbcrCAQrtymkNuhKP
2026-09-07 20:43:51 +00:00

1.6 KiB

topic, source_keys
topic source_keys
fetch
git-scm-fetch-docs
context7-git-htmldocs

Fetching

Fetch with no refspec updates remote-tracking branches (refs/remotes/<name>/*) and leaves every local branch alone.

That safety comes from the default refspec, not from fetch itself. Give it an explicit one and it writes to local branches: verified on Git 2.39.5, git fetch origin main:probe fast-forwarded the local probe branch, and a + prefix force-updates the destination, discarding whatever commits it held. Treat any fetch carrying a <src>:<dst> refspec as a branch update, not a read.

  • One remote: rtk git fetch <remote> — all branches
  • One branch: rtk git fetch <remote> <branch> — the result lands in FETCH_HEAD, not a tracking ref
  • All remotes: rtk git fetch --all
  • Prune properly: rtk git fetch --all --prune --prune-tags cleans stale branches and tags
  • Auto-prune: rtk git config --global fetch.prune true (or remote.<name>.prune to scope it to one remote), and fetch.pruneTags true for tags

Shallow and partial fetch

rtk git fetch --depth=<n>             # deepen history, or create a shallow clone
rtk git fetch --unshallow             # convert a shallow clone to full history
rtk git fetch --update-shallow        # allow the fetch to update the shallow boundary
rtk git fetch --refmap='' <remote> <branch>  # fetch without updating any tracking ref (FETCH_HEAD only)

Default fetch refspec

The default is +refs/heads/*:refs/remotes/<name>/*. The leading + forces the update — remote-tracking branches always mirror the remote exactly and offer no protection for local history.