Git and Windows Vista

I re­cently started using Git, the ver­sion con­trol sys­tem now used for de­vel­op­ing the Linux Ker­nel. While there is no na­tive sup­port for Win­dows at the mo­ment, you can in­stall it using cyg­win. While this works rea­son­ably well in Win­dows XP, I got into se­vere trou­bles when try­ing the same in Win­dows Vista.

First, I ran into trou­bles in­stalling cyg­win. I fig­ured out, that it seems to work well if you run both the in­staller and bash in “Win­dows XP SP2 com­pat­i­bil­ity mode”. I needed to ad­just the file sys­tem per­mis­sions of the cyg­win folder to give me write per­mis­sions, though. (Note: you have to man­u­ally in­stall the TK-libs if you want the GUI el­e­ments of git to work.)

But Git kept fail­ing with “ac­cess de­nied” mes­sages when try­ing to com­mit from com­mand line. The fail­ure mes­sage said it was de­nied ac­cess to git-update-index. I soon found out this is due to the “User Ac­count Con­trol” (UAC) de­fault be­hav­ior of auto-de­tect­ing in­stallers and prompt­ing if you want to ex­e­cute them with raised priv­i­leges. You can see if this is the case by run­ning git-update-index man­u­ally from bash; if you get the UAC con­fir­ma­tion di­a­log you have this prob­lem. It seems the sub­string “up­date” trig­gers this be­hav­ior. As the git-update-index is launched by git commit, it won’t dis­play the con­fir­ma­tion di­a­log of Vista, so the ex­e­cu­tion will be de­nied.

There are two pos­si­ble workarounds:

  • Run bash with ad­min­is­tra­tive priv­i­leges (not rec­om­mended!)
  • Dis­able the auto-de­tec­tion of in­stallers by UAC.

I used the lat­ter way. You can dis­able the auto-de­tec­tion by fol­low­ing these in­struc­tions. Brief sum­mary:

  • Open the Local Se­cu­rity Poli­cies
  • Dis­able “User Ac­count Con­trol: De­tect ap­pli­ca­tion in­stal­la­tions and prompt for el­e­va­tion”
  • Re­boot (the se­cu­rity pol­icy will not be up­dated be­fore!)

It should work now. You can con­firm this by run­ning git-update-index man­u­ally again. If you do not get the UAC con­fir­ma­tion di­a­log now, it worked. Try git commit now, and ver­ify it is work­ing. Of course, you will from now on have to right-click and “Run as Ad­min­is­tra­tor” every in­staller you want to in­stall, as most in­stallers will re­quire ad­min­is­tra­tive priv­i­leges.

Up­date 2007-08-22: Reader EGar­cia posted an in­ter­est­ing com­ment below: using the Mi­crosoft Man­i­fest Tool you can add an ac­cord­ing man­i­fest to the git-up­date-in­dex.exe and git-up­date-ref.exe

Up­date 2009-02-12: Reader Kevin Broadey points out the best so­lu­tion so far: cre­ate a seper­ate .man­i­fest file for the af­fected files. He has pro­vided an ex­am­ple for git-up­date.​exe.​manifest.

13 thoughts on “Git and Windows Vista”

  1. You’re a lifesaver. Thank you sir. In my setup, I didn’t get the confirmation dialog at all, just a straight permission denied error whether I went through git commit or straight through git-update-index.exe

    Everything else matched your description.

  2. Glad I could help you.
    It might be that I got the confirmation dialog because I start bash in Windows XP SP2 compatibility mode. But this is just a blind guess. I will have to check one day. 😉

  3. After sharing your interest in ‘git’, reading your article and rejecting all solutions you presented, I wanted to share a solution which worked for me. Using Microsoft’s Manifest Tool, I added a manifest to git-update-index.exe which eliminated my git + UAC: ‘Permission denied’ problems.

  4. Hi,

    I just ran into this post, not sure if it’s fixed. What I did was to run cygwin on my non-OS partition (ie. D:\ or E:\) and it works for me. Vista is VERY protective of its OS partition and file operations there by “guests” are not welcomed. I didn’t need to do anything to my UAC (it’s still running), etc.

    Hope this would help someone… 🙂

  5. Hmm, maybe this was udpated in Vista with SP1? The detection of installers was revised as far as I read on the net, so this would have an effect on your observation. Being on the system partition or not should have no effect on the UAC being triggered by setup programs.

    Thanks for sharing your observation!

  6. You can create a separate git-update-index.exe.manifest file in your /usr/sbin/git-core directory rather than messing with the Microsoft Manifest tool. The file below works for me. You will need to create similar files for git-update-index.exe and git-update-server-info.exe too.

    Don’t assume I have god-like powers – I found this solution elsewhere on the internet (okay, Google found it for me!)

    The important bit is setting requestedExecutionLevel level=”asInvoker” which side-steps Vista’s automatic installer detection heuristics.

    Here’s an article about installer detection – http://msdn.microsoft.com/en-us/library/bb756960.aspx

    And here’s a link to the XML manifest format – http://msdn.microsoft.com/en-us/library/bb756929.aspx

  7. Just an FYI for anyone that runs into this: if you create the .manifest and still get “permission denied” or “This operation requires elevation” when running the cygwin executable, “touch” the executable to change its modification date. It seems the executable’s .manifest (or lack thereof) gets cached– even across a reboot for me.

Leave a Reply to EGarcia Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.