#11904·dolt

git+https remote: Windows push fails on FETCH_HEAD 'Permission denied'; redundant fetch fan-out, no --no-write-fetch-head, console per git spawn

Author: davidcforbesCreated Sep 20, 2026Updated Sep 30, 2026
Labelsbugwindowsgood reprocustomer issue

Summary

On Windows, pushing to a git+https:// remote fails reliably with a bogus Permission denied on the cache repo's FETCH_HEAD. Three separable defects in store/blobstore contribute; each is independently fixable and the first is close to free.

Error 1105: failed to get remote db; the remote: origin 'git+https://github.com/<owner>/<repo>.git'
could not be accessed; error: cannot open
'...\.dolt\git-remote-cache\<hash>\repo.git/FETCH_HEAD': Permission denied

The four credential hints printed alongside are misleading — see (4). Credentials are fine: plain git ls-remote <same remote> succeeds from the same shell, and dolt fetch against the same remote and cache succeeds. Only push fails.

Environment: Windows 11 (26200), git 2.55.0.windows.5, dolt 2.3.5, embedded via github.com/dolthub/dolt/[email protected]. Reproduced on several repos on two machines; 100% on some, intermittent on others. Line numbers below are current main as of 2026-09-20 and match the pinned module.


1. FetchRef never passes --no-write-fetch-head, and nothing in dolt reads FETCH_HEAD

store/blobstore/internal/git/impl.go:393:

go
_, err := a.r.Run(ctx, RunOptions{}, "fetch", "--no-tags", "--refmap=", remote, refspec)

FETCH_HEAD is vestigial on this path: the fetch uses an explicit refspec plus --refmap=, and the destination ref is read afterwards. Grepping the entire dolt Go source for FETCH_HEAD returns zero matches — it is never read anywhere. Suppressing the write is therefore functionally inert.

This cannot be fixed from outside: git honours --no-write-fetch-head only as a command-line flag. fetch.writeFetchHEAD=false is ignored on this path (verified directly: config resolved to false, file recreated anyway). Only the code building the argv can pass it.

2. The write path fetches unconditionally, with no dedup — and the fan-out scales with backlog

A single push issues many byte-identical fetches, all resolving to one destination ref. Captured via GIT_TRACE:

trace: built-in: git fetch --no-tags --refmap= origin +refs/dolt/data:refs/dolt/remotes/origin/dolt/data/<uuid>

Measured: 7 identical invocations on a small repo, 16 and then 21 on a repo with a growing unpushed backlog — same command, same single destination UUID each time.

The cause is visible in the code. store/blobstore/git_blobstore.go has a dedup guard whose own comment excludes the write path:

go
// Dedup guard: skip the fetch if we synced recently. The write path
// (fetchAlignAndMergeForWrite) always does its own unconditional fetch,
// so this only affects read-path callers (Get/Exists).

and immediately above the read-path fetch:

go
// Concurrent fetches contend with an in-progress push on slow remotes.
if gbs.writeInProgress.Load() { return nil }

fetchAlignAndMergeForWrite opens with an unconditional FetchRef and has neither guard. So fetch count tracks the number of write operations, which grows with unpushed backlog — the bug is self-worsening: each failed push widens the next fan-out. Early retries occasionally succeeded; once a backlog accumulated they stopped succeeding at all.

Since every fetch in a run is identical and targets one ref, deduplication looks like a clear win independent of the FETCH_HEAD question — it is also a lot of redundant network work.

3. Git child processes are created without suppressing a console (Windows)

store/blobstore/internal/git/runner.go:45 resolves git with a bare exec.LookPath("git") and spawns it with no Windows creation flags. On Windows a console-subsystem child started from a parent with no console of its own does not inherit one — the OS allocates a new console. When the host process is a service, hook, or detached child, each spawn becomes a visible window; with Windows Terminal as the default terminal application that is ~21 windows per push.

CREATE_NO_WINDOW is the appropriate flag here (the child keeps a console object, so console-state queries still work, but it is never displayed).

NewRunnerWithGitPath (runner.go:53) is referenced only from impl_test.go, so there is no production injection point for the binary or the argv — this is not workaroundable by an embedder.

4. The error path prints credential advice for a local file-open failure

libraries/utils/gitauth/normalize.go:39-40 emits, unconditionally on this error path:

hint: dolt does not support interactive credential prompts
hint: configure git credentials (credential helper, token) for HTTPS remotes

A local EACCES on FETCH_HEAD has nothing to do with credentials. This sent multiple people hunting a GCM/token problem that did not exist; one spent hours on it. Gating these hints on actually-auth-shaped failures would save real triage time.


Reproduction of the underlying file conflict

The error is reproducible with no dolt involvement — hold FETCH_HEAD with a restrictive share mode and run the same fetch:

powershell
$fs = [IO.File]::Open("$R\FETCH_HEAD", 'Open', 'Read', 'Read')
git --git-dir="$R" fetch --no-tags --refmap= origin '+refs/dolt/data:refs/dolt/remotes/origin/dolt/data/<uuid>'
# -> error: cannot open '...repo.git/FETCH_HEAD': Permission denied

POSIX would not care, which is why this is Windows-only.

A supporting signature: FETCH_HEAD measures 104 bytes before a failing push and 0 bytes after (successful fetches leave 232-1261 bytes). Note this is not diagnostic on its own — git truncates FETCH_HEAD on open and writes it at the end, so any failure in that window leaves it empty regardless of cause.

Ruled out (each measured, so nobody repeats them)

  • fetch.writeFetchHEAD=false, repo-local and via scoped global includeIf — ignored on this path.
  • gc.auto=0 / gc.autoDetach=false / maintenance.auto=false — failures continued. Note git maintenance run --auto --no-quiet --detach still appears twice per push in the trace despite these.
  • Priming the cache with a manual fetch first; waiting for all git processes to exit; re-cloning the cache repo.
  • Antivirus: an exclusion covering the whole working root changed nothing (byte-identical failure afterwards).
  • Raw process concurrency alone: 16 concurrent plain git fetch into the same cache repo succeeded 16/16.

That last pair is why we are reporting the code shape rather than a single root cause: the redundant unguarded fan-out is the part that is clearly wrong in the source, regardless of what ultimately wins the race on a given machine.

Requests, in order of cost

  1. Pass --no-write-fetch-head in FetchRef (inert; nothing reads the file).
  2. Dedupe or serialise the write-path fan-out, or extend the existing writeInProgress/TTL guards to it.
  3. Create git children with CREATE_NO_WINDOW on Windows.
  4. Stop printing credential hints for local file-open failures.

Happy to test patches — this reproduces reliably here.