May 7, 2016

Stupid Git Tricks: 1 of N

To the surprise of some developers outside of Microsoft, my team uses Git for the vast majority of our code (10,000+ lines of code). Since we work on Windows, Git is built by using a bastardized subset of Cygwin to provide some of the POSIX facilities it requires. This generally works but there is some cruft and ugliness that occasionally rears its ugly head.

Recently, I performed a clean install of Windows 10 on my work laptop. Shortly thereafter, I started encountering a puzzling issue with Git when I was working from home. Any time I’d ask Git to do an operation that required hitting the wire or talking with the origin, it would inexplicably hang. Eventually, it would crash and spew some error that was largely meaningless.

After googling for a couple of hours, I found issue 493 on GitHub for the git-for-windows project. Apparently Git is poorly behaved with whatever changes occurred in the users/groups APIs when the machine is unable to resolve the domain controller. To mitigate this issue, a workaround was identified where you would install Cygwin and copy its settings for POSIX groups and passwd, working around Git trying to resolve the domain controller.


Assuming that your Cygwin installation was C:\cygwin\ and that your Git for Windows installation is at C:\Program Files\Git\:

  1. Install Cygwin
  2. From a Cygwin Bash prompt, type in the following:
    getent passwd $(id -u) > /etc/passwd
    getent group $(id -G) > /etc/group
  1. Copy C:\cygwin\etc\passwd to C:\Program Files\Git\etc\passwd
  2. Copy C:\cygwin\etc\group to C:\Program Files\Git\etc\group

Now, if you’re off of your office network, you should be able to push/pull without issue.

Some Side Notes

  • I’m on a domain joined laptop.
  • I’m using Git Credential Manager to seemlessly pass my credentials to Visual Studio Team Services (formerly VSO)

howto git

Previous post
Adventures in Gigabit Internet In my never ending pursuit of novelty, I recently acquired gigabit internet. I discovered back in November of 2015 that CenturyLink would begin
Next post
Haskell & Stubbornness A persistent theme for the entirety of my adult life as a programmer has been attempting to learn the Haskell programming language. Everything about