git status仅在“以管理员身份运行"时才正确,这是Windows VirtualStore引起的问题 [英] git status only correct if "Run As Administrator", problems due to Windows VirtualStore

查看:134
本文介绍了git status仅在“以管理员身份运行"时才正确,这是Windows VirtualStore引起的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我写的Excel插件的git存储库,因此路径为"C:\ Program Files \ Microsoft Office 15 \ root \ office15 \ Library \ BTRTools"("Library"路径是必需的安装父目录) Excel加载项使它们能够正常工作,因此我无法对其进行更改).我在Win7和Win8.1中都打开了UAC.在Win7中,一切正常,但是在Win8.1中,我的状态基本上是一切都已更改"(但即使是一些奇怪的文件,首先被称为已删除",然后又以与未跟踪"相同的状态被提及.存储库的确是尽管git status所说的是干净",但我无法拉出或重置--hard或其他任何东西.

I have a git repository for an Excel Addin I wrote, so the path is "C:\Program Files\Microsoft Office 15\root\office15\Library\BTRTools" (That 'Library' path is the required install parent of Excel add-ins for them to work properly, so I can't change it). I have UAC turned on in both Win7 and Win8.1. In Win7 everything works fine, however in Win8.1 I get a status of basically 'everything changed' (but even some weirder stuff of files first mentioned as 'deleted' then mentioned again in same status as 'untracked'. The repository is really 'clean', despite what git status says, but I can't pull or do reset --hard or anything.

如果我使用以管理员身份运行"选项运行"Console2"(我从中发出git bash命令的应用程序),则一切正常,状态为干净(未列出更改).而且我可以正确执行pull和其他任何命令.

If I run 'Console2' (the app from which I issue git bash commands from) using the 'Run As Administrator' option, everything works fine and the status is clean (no changes listed). And I can do a pull and any other command correctly.

在Win7和Win8.1中,我已经为用户手动授予了BTRTools文件夹的完全访问"权限(即使我已经是两者的Administrators组的成员),并验证了Console2确实以我的本地用户身份运行Win8.1.

In both Win7 and Win8.1 I have manually granted Full Access rights to the BTRTools folder for my user (even though I am already part of the Administrators group in both) and verified that Console2 is indeed running as my local user in Win8.1.

任何人以前都曾遇到过此问题,并且对如何使Console2/git在Win8.1中正常工作而又不求助于始终以以管理员身份运行"模式运行Console2(得到提示)有任何想法吗?

Has anyone experienced this problem before and have any ideas on how I can get Console2/git to work properly in Win8.1 without resorting to always running (getting prompted) Console2 in 'Run As Administrator' mode?

谢谢.

更新

我发现我在特定条件下在Win7中也有相同的行为.我编写了一个脚本,以通过创建和运行c# Process/ProcessStartInfo 来批处理多个git命令,该脚本显示的行为与Win8.1 Console2相同.在Win7控制台和Win7脚本中直接调用完全相同的命令(即git状态)显示了两个不同的结果.

I discovered I got the same behavior in Win7 under a specific condition. I wrote a script to batch process several git commands by creating and running a c# Process/ProcessStartInfo and it was displaying the same behavior as the Win8.1 Console2. Calling the exact same commands directly in Win7 console vs the Win7 script (i.e. git status) displayed two different results.

该脚本(用LINQPad编写)以我的当前用户身份运行,但是我假设它在创建并启动 Process/ProcessInfo 时以某种方式在其他用户下运行.我可以通过提供 my 凭据

The script (which was written in LINQPad) was running as my current user, but I am assuming that when it created and launched a Process/ProcessInfo it was somehow running under a different user. I was able to correct this problem in my script by providing my credentials

p.UserName = Environment.UserName;
p.Password = new System.Security.SecureString();
foreach( var c in password.ToCharArray() )
{
    p.Password.AppendChar( c );
}

注意:我已验证Win7和Win8.1中我"用户的安全组/设置似乎相同(属于管理组).

Note: I verified that the security groups/settings for the 'my' user in both Win7 and Win8.1 appear to be same (part of Admin group).

更新:获取ACL输出

我运行了Get-ACL |两台机器上/BTRTools目录中的format-list.唯一的区别是Win8基本上对所有文件夹都具有应用程序包授权",而Win7则没有.不知道这是否暗示什么.

I ran Get-ACL | format-list on the /BTRTools directory on both machines. The only difference was that Win8 had 'Application Package Authority' for basically all folders and Win7 did not. Not sure if that hints towards anything.

更新:已解决

感谢@ ian-boyd向我指出了正确的方向.在我的Console2/Git可以正常工作的Win7机器上,我发现我有以下文件:

Thanks to @ian-boyd for pointing me in right direction. On my Win7 machine where Console2/Git work fine, I discovered I had the following file:

C:\ Users \ terry.aney \ AppData \ Local \ VirtualStore \ Program Files \ Microsoft Office 15 \ root \ office15 \ Library \ BTRTools.git \ index

C:\Users\terry.aney\AppData\Local\VirtualStore\Program Files\Microsoft Office 15\root\office15\Library\BTRTools.git\index

我不确定何时创建.如果删除它,则Win7上的Console2/Git会开始失败",就像Win8表现出的行为一样.我在Win7上将其还原,然后将其复制到Win8,现在Console2/Win8也可以正常运行.我有更大的战斗要战斗,所以我继续前进.我对此不太了解,不过,请注意,这是我尝试过的一些步骤

I'm not sure when that was created. If I removed it, my Console2/Git on Win7 started to 'fail' just like the behavior Win8 was presenting. I restored it on Win7, and copied it over to Win8 and now Console2/Win8 is behaving correctly as well. I've bigger battles to fight so I'm moving on. I don't really understand this, but as a side note, here were some of the steps I tried

  • 根据此页面设置对Users组\ Git安装目录的完整文件/目录访问权限
  • 关闭#1中同一页面上的虚拟化文件和注册表写入失败到每个用户位置.
  • 设置用户"组对\ Library目录的完整文件/目录访问权限.
  • Setting full file/directory access to \Git install directory for Users group per this page
  • Turning off Virtualize file and registry write failures to per-user locations per the same page in #1.
  • Setting full file/directory access to \Library directory for Users group.

如果有人对处理此问题的正确"方式有任何意见,我将不知所措.

If anyone has any opinions on the 'correct' way to handle this, I'm all ears.

推荐答案

我的猜测是Git试图在无法访问的地方写入文件.

My guess is that Git has attempted to write files where it does not have access.

然后Windows尝试通过将写重定向到其他地方来保持越野车Git的运行.检查您的

Windows then tries to keep the buggy Git going by re-directing the write someplace else. Check your

%AppData%\ Local \ VirtualStore

%AppData%\Local\VirtualStore

用于重定向写入的文件夹.例如:

folder for redirected writes. For example:

C:\Users\Ian\AppData\Local\VirtualStore\Program Files\Microsoft Office 15\root\office 15\Library

我的猜测是您将在其中找到文件.

My guess is you will find files there.

正确编写的Windows应用程序应包含一个嵌入式选项,该选项要求Windows 重定向失败的写入.但是我猜测Git不是一个正确编写的Windows应用程序.

A correctly written Windows application would include an embedded option that asks Windows to not redirect failed writes. But i'm guessing Git is not a correctly written Windows application.

来自了解和配置Windows中的用户帐户控制Vista

用户帐户控制:虚拟化文件和注册表写入每个用户位置的失败

此设置定义32位应用程序的虚拟化设置.虚拟化不适用于64位应用程序.

User Account Control: Virtualize file and registry write failures to per-user locations

This setting defines virtualization settings for 32-bit applications. Virtualization does not apply to 64-bit applications.

配置选项:

  • 已启用-如果没有清单文件的32位应用程序尝试写入受保护的位置(如Program Files目录),则虚拟化会将这些操作重定向到文件系统和注册表中所有用户都可以访问的位置.此设置使标准用户可以运行Windows Vista以前的应用程序,这些应用程序历来要求运行该程序的用户为管理员.
  • 已禁用-如果没有清单文件的32位应用程序尝试写入程序文件目录之类的受保护位置,则写入将失败并且该应用程序将以静默方式运行.

默认值:已启用

建议:在必须运行与UAC不完全兼容的软件的环境中,请启用此设置.没有应用程序清单文件或应用程序数据库条目的任何32位非管理应用程序都不符合UAC.许多企业必须运行Windows Vista之前的软件,因此,应将此设置配置为 Enabled .

Recommendation: Keep this setting enabled in environments where software must be run that is not fully compliant with UAC. Any 32-bit non-administrative application without an application manifest file or an application database entry is not UAC compliant. Many enterprises must run pre Windows Vista software, and therefore, should keep this setting configured to Enabled.

这篇关于git status仅在“以管理员身份运行"时才正确,这是Windows VirtualStore引起的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆