Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Configuration Options

fetch.prune and fetch.parallel settings

Reference for fetch.prune, fetch.pruneTags, fetch.parallel, fetch.recurseSubmodules and fetch.writeCommitGraph: tidy remote-tracking refs and speed up fetches.

git fetch downloads new commits and updates remote-tracking branches such as origin/main. The fetch.* settings change what else it does. The most useful one, fetch.prune, deletes remote-tracking branches whose branch no longer exists on the server, so your git branch -r list stops accumulating dead entries.

Terminal
git config --global fetch.prune true
git config --global fetch.parallel 4
git config --global fetch.writeCommitGraph true

Try it

Bash Stale tracking branches and prune

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash pruneTags and parallel

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
git config fetch.prune (true | false)
git config fetch.pruneTags (true | false)
git config fetch.parallel <n>
git config fetch.recurseSubmodules (true | false | on-demand)
git config fetch.writeCommitGraph (true | false)
git config fetch.fsckObjects (true | false)
git config fetch.unpackLimit <n>
Name Description
fetch.prune Remove remote-tracking refs that no longer exist on the remote (same as git fetch --prune).
fetch.pruneTags Also remove local tags that no longer exist on the remote. Works together with prune.
fetch.parallel How many submodules or remotes to fetch at once. 0 picks a number based on CPUs; 1 (default) is sequential.
fetch.recurseSubmodules Fetch submodules too. Default on-demand fetches only changed ones.
fetch.writeCommitGraph Update the commit-graph file after fetching, which speeds up later git log and merge-base queries.
fetch.fsckObjects Check received objects for corruption (falls back to transfer.fsckObjects; see transfer.fsckObjects).
fetch.unpackLimit Objects below this count are stored loose; above it, the pack is kept.

Edge cases: pruning only touches refs under the destination namespace of the fetch refspec (normally refs/remotes/<remote>/); local branches are never deleted.

Usage notes

  • fetch.prune is safe. It deletes only remote-tracking refs, which Git recreates on the next fetch if the branch comes back. Your own work is not touched.
  • pruneTags is riskier. A local tag that you never pushed disappears if the remote has no such tag, because the effective refspec becomes refs/tags/*:refs/tags/*.
  • Setting per remote: remote.<name>.prune and remote.<name>.pruneTags override the global values.
  • fetch.parallel helps repositories with many submodules or when fetching a group of remotes (git fetch --all); a single remote with one repository is not made faster.
  • What fetch never does: it does not change your working tree or local branches. Use git pull or git merge for that.
  • Maintenance: fetch.writeCommitGraph is mostly useful in large repositories; git maintenance can do the same job in the background.