Sunday, January 11, 2009

Git on Windows 7

I use Git everyday, whether it be for IronRuby, AgDLR, or random other Rails/Ruby work. Being that I work at Microsoft, I got my hands on earlier build of Windows 7 during the fall. Unfortuantely, git didn’t work fully on Windows 7, failing whenever a merge happened, which made push fail, as well as pull when trying to get other people’s changes). Jim Deville has been tracking this with the Windows team, and even bringing it up to the msysgit maintainer to see if there’s any way around this. It was looking grim, so I left my main development machine on Vista, and was sad.

Windows 7 Beta was released this past Friday, and I managed to download the .iso, get a Product Key, etc, at home during the day on Saturday. Now that it’s released, I’m guessing other people will have this problem ...

I’m not sure of the specific details behind the issue, but msysgit calls into C:\windows\system32\msvcrt.dll during a merge, and the changes to that DLL in Windows 7 breaks msysgit. Last week, John Lam was describing the issue to John Messerly, and realized that the easiest fix would be to copy the Windows Vista msvcrt.dll to the C:\Program Files\Git\bin directory, since Windows DLL resolution will look on the PATH, and “.” is included.

Curt Hagenlocher just reminded me of the fix, and it works!

gitwin7

Pretty awesome. Enjoy Git in Windows 7!

10 comments:

Anonymous said...

Sorry, but it is really Windows' fault, breaking backwards compatibility in such a blatant way. After all, it is the C runtime, part of the C standard, that we are talking about.

Jimmy Schementi said...

Yes, it is Windows' fault, and they should fix it for the final release of Win7. I never said that it wasn't Windows' fault, so no need to be sorry.

But to fix it now, and get Git running on Windows 7, this is the work-around.

charlesroper said...

This is why such broad-ranging public betas are so important. Thanks for the temporary work-around; much obliged. :)

bearassbear said...

this will be really handy when i get home. i put windows 7 on my laptop and my girlfriend is always taking over my desktop.

nickhodge said...

@bearassbear

you have three choices:

get a new girlfriend

or purchase another laptop.

or both.

stimpy77 said...

Out of curiosity, when will Microsoft build on SUA? When will anyone in the *nix communities abandon Cygwin/MinWin for SUA? If SUA can't cut it, why not make it better? If it's a home-version Windows issue (SUA isn't available on thsoe), why not make it available on Home editions? Should we forever keep throwing SUA out for MinWin/Cygwin?

Anonymous said...

The fix does not seem to work with the latest versions of Git, 1.6.1 works but 1.6.2.1 doesn't.

Viktor said...

Thank you very much for info on how to work around it! I had to use version 1.6.1 of Git though. (So the post above seems to be correct)

Anonymous said...

Windows 7 final still has this problem, at least for me.. push with a merge fails.

According to this post, I should:

-Downgrade to msysgit 1.6.1
-Locate a msvrrt.dll from a Vista and copy to the bin dir of msysgit.

It is a shame for microsoft developers that dlls are not back compatible, it has happened several times: VisulBasic did it a couple of times (begore .net), mcvsrt.dll did it also in the past (V4 and 5 I think), and now again with Windows 7... a great shame for microsoft developers, and a pain for the rest of us.

Sergio Hernandez said...

Just for others that could come with the same problem:

Lates version 1.7.x didn't worked for me on Win7 64bits, push with a merge didn't work.

Using the msvcrt.dll V6 (Vista) instead of V7 (Win7) didn't solve it.

Downgrading to V1.6.1 worked fine, without using any dll or changing anything... this far, V1.6.1 worked ok for me "out of the shell" on a Win7 64 bits.