Dmitry Leskov

It’s Been a Long Time Since I Had To Patch a Binary Executable…

Needed to push a file created on a notebook the other night to a Git repo on a desktop, both running Windows and connected to my home router. Thought the git protocol would work. It did not due to a bug in msysgit. (TL/DR: the bug has been open since March 2010, but nobody so far has volunteered to find the root cause and remedy, or sponsor such an effort. The only sensible workaround is to recompile msysgit from source with the side-band-64k protocol capability disabled, as the older side-band does not exhibit the problem, but the newer, faster alternative always takes precedence if both client and server support it.)

Followed the advice from Eli Billauer’s blog and patched git.exe on my desktop, which plays the role of a “central” Git server.

Here is a patch script that worked for me. It requires Gsar for Windows from the GnuWin32 collection; CygWin likely includes gsar too.

@echo off
copy /-y git.exe git.exe~
if errorlevel 1 goto copyfailed
gsar -o -sside-band-64k -rKW6YzEZbBv584 git.exe
if errorlevel 1 goto patchfailed
echo git.exe successfully patched
goto quit
echo Could not create a backup copy of git.exe
goto quit
echo Could not patch git.exe with GSAR
goto quit

The value of the -r option is just a random 13-character string generated by DuckDuckGo using the query password 13. You may wish to use different values on each Windows machine you may be pushing to using the git protocol.

Tags: , ,

« | »


  1. Jonathan Bartlett
    3:46 am

    Note that in current git-for-windows you can use the following instead of patching your binary:

    git config –global sendpack.sideband false

* Copy This Password *

* Type Or Paste Password Here *