Git "fatal: the remote end hung up unexpectedly" in CI
The remote closed the connection before the transfer finished. On a large push or clone this is usually a buffer or timeout cutting off the stream, not a problem with the repository itself.
What this error means
A clone, fetch, or (most often) a git push of many/large objects fails with fatal: the remote end hung up unexpectedly, sometimes after "Writing objects" reaches 100%. Smaller pushes succeed; the big one drops.
Writing objects: 100% (1242/1242), 312.40 MiB | 4.21 MiB/s, done.
fatal: the remote end hung up unexpectedly
fatal: sha1 file '<stdout>' write error: Broken pipeCommon causes
A large transfer exceeding a proxy/server limit
A big push or clone over HTTPS can exceed a proxy body-size limit or idle timeout, so the far end closes the connection mid-stream.
Transient network drop
A brief connectivity blip aborts the in-flight transfer. Nothing is wrong with the repo - a retry often completes.
How to fix it
Raise the HTTP post buffer
A larger buffer lets Git send bigger chunks before flushing, which avoids tripping small proxy limits on a large push.
git config --global http.postBuffer 524288000 # 500 MBShrink the transfer or push in batches
- Clone shallow (
--depth 1) so a fetch moves far less data. - For a huge first push, push in smaller commit ranges rather than one giant pack.
- Switch to the SSH remote if HTTPS proxies keep truncating the transfer.
Retry the transient drop
If the disconnect is intermittent, a bounded retry around the operation usually succeeds on the next attempt.
for i in 1 2 3; do
git push origin main && break
echo "push failed (attempt $i), retrying..."; sleep 5
doneHow to prevent it
- Raise
http.postBufferon runners that push large packs through a proxy. - Use shallow clones in CI to keep transfers small.
- Prefer SSH for large pushes behind body-size-limited HTTPS proxies.