Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Configuration Options

transfer.fsckObjects setting

Reference for transfer.fsckObjects, fetch.fsckObjects and receive.fsckObjects: check every incoming object for corruption, and tune it with fsck.* settings.

transfer.fsckObjects makes Git run the same integrity checks as git fsck on every object that arrives during a fetch, clone or push. Without it Git still checks that the data it receives is intact (each object's hash matches its content), but it does not check that the objects are well formed. A commit with a mangled author line, a tree with a duplicate entry or a path such as .git hidden in a tree would be accepted and stored.

Turning it on costs some CPU time for large transfers and protects you, and everyone who later pulls from your server, from malformed or malicious objects. Hosting providers enable the equivalent on their side.

Terminal
git config --global transfer.fsckObjects true
git config receive.fsckObjects true      # inside a bare server repository
git config fetch.fsckObjects true        # only for fetch and clone

Try it

Bash A malformed commit is rejected on push

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 Which setting wins

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 [--global] transfer.fsckObjects <true | false>
git config fetch.fsckObjects <true | false>
git config receive.fsckObjects <true | false>
git config fsck.<message-id> <error | warn | ignore>
git config fsck.skipList <file>
git config fetch.fsck.skipList <file>
git config receive.fsck.skipList <file>
Setting Applies to
transfer.fsckObjects Default for both directions: fetch and clone (client) and push (server).
fetch.fsckObjects Objects downloaded by git fetch, git pull and git clone. Overrides transfer.fsckObjects.
receive.fsckObjects Objects uploaded to a repository you host. Overrides transfer.fsckObjects.
fsck.<msg-id> Raise or lower the severity of one kind of problem (for example missingEmail, badTimezone, zeroPaddedFilemode).
fsck.skipList Path of a file listing object IDs (one per line) that checks should ignore. Prefix with fetch. or receive. to limit it to one direction.

Edge cases: the default for all three keys is false. The fsck.* severities apply to git fsck as well as to the transfer checks. A problem set to ignore is not reported; warn is printed but does not stop the transfer; error stops it.

Usage notes

  • It checks structure, not authorship. The check finds malformed commits, tags and trees, duplicate tree entries, bad file modes, unsafe paths such as .git or names that collide on case-insensitive file systems, and a few security-sensitive .gitmodules patterns. It cannot tell whether a commit really comes from the person named in it; that is what signing is for.
  • Servers should enable receive.fsckObjects. A bad object that reaches a shared repository is copied to every clone and is hard to remove later, since objects are referenced by hash. Rejecting it at the door is cheap.
  • Old history can fail. Some long-lived repositories contain commits with problems that were tolerated years ago (zero-padded modes, bad timezones, missing emails). When a clone aborts with fsck error, either set fsck.<msg-id> to warn for that kind of problem or add the exact objects to a skip list instead of turning the whole check off.
  • Cost: the checks run while objects are unpacked or indexed, so an initial clone of a large repository gets measurably slower. The cost is linear in the number of new objects.
  • A protection against hostile servers. Several path-based attacks (for example a tree containing .git/config or a symlinked .gitmodules) were fixed in Git, and transfer.fsckObjects rejects such trees before they can be checked out.
  • git fsck finds the same problems later, which helps for objects that arrived before you enabled the setting. See git fsck.
  • The bad object is rejected, not repaired. The client must create a new, valid commit and push that.