简体   繁体   English

Windows上的Git结帐和重置偶尔会显示随机文件已更改

[英]Git checkout and reset on Windows occasionally shows random files have changed

Often when I do a checkout of a different branch, or a reset, I will get 'permission denied' errors from windows for one to a dozen files - but the particular files vary from run to run. 通常当我检查不同的分支或重置时,我会从一个到十几个文件的窗口中获得“权限被拒绝”错误 - 但是特定文件因运行而异。 Here's the output from a test I just did, with GIT_TRACE=1. 这是我刚刚做过的测试的输出,GIT_TRACE = 1。 The trace only added the one line before the error message: 跟踪仅在错误消息之前添加了一行:

$ git checkout master
trace: built-in: git 'checkout' 'master'
error: git checkout-index: unable to create file dotnet/src/myfile.cs (Permission denied)
D       dotnet/src/myfile.cs
Switched to branch "master"

I'm pretty sure this is some race with a virus scanner or other indexing service on my machine. 我很确定这是在我的机器上使用病毒扫描程序或其他索引服务的比赛。 If the race persisted, I could use sysinternals to see what process has the file handle open. 如果竞争持续存在,我可以使用sysinternals来查看文件句柄打开的进程。 However, it happens very quickly, and I'm not aware of a tool that will show me this conflict. 但是,它发生得很快,我不知道有一个工具可以告诉我这个冲突。 Surprisingly, I haven't found anyone describing similar behavior. 令人惊讶的是,我没有发现任何描述类似行为的人。 How do I make these errors stop, or diagnose the problem further? 如何使这些错误停止或进一步诊断问题?

I'm specifically looking to end the file access race by identifying whatever process is doing the simultaneous access. 我特别希望通过识别正在进行同步访问的进程来结束文件访问竞争。 So suggestions for a tool that shows which process has a file locked when an edit is denied would be very helpful. 因此,对于在拒绝编辑时显示哪个进程具有文件锁定的工具的建议将非常有用。 I'm aware of 'unlocker' and similar tools which will show me what process holds a file locked for a period of time. 我知道'解锁器'和类似的工具会告诉我哪个进程持有文件锁定一段时间。 This doesn't work for this issue, because the process keeps the file locked for a very short period. 这不适用于此问题,因为该过程会在非常短的时间内锁定文件。 So the tool needs to collect the appropriate data without my intervention, as I'm too slow. 所以该工具需要在没有我干预的情况下收集适当的数据,因为我太慢了。

It might be the Windows Search Indexer, which tries do index files as they are created. 它可能是Windows搜索索引器,它会在创建索引文件时尝试执行索引文件。 I ran into this issue with svn checkout and had to exclude that directory from indexing before I could successfully checkout a full project. 我使用svn checkout遇到了这个问题,并且在成功签出完整项目之前必须从索引中排除该目录。

See my post https://connect.microsoft.com/VisualStudio/feedback/details/676699/cannot-open-linker-output-for-writing-or-cannot-close-file 请参阅我的帖子https://connect.microsoft.com/VisualStudio/feedback/details/676699/cannot-open-linker-output-for-writing-or-cannot-close-file

Not git related! 不是git相关的!

Sysinternals' process monitor reveals that Windows explorer interferes with newly created files, perhaps due to some plugin or what, but it happens. Sysinternals的进程监视器显示Windows资源管理器干扰了新创建的文件,可能是由于某些插件或什么,但它发生了。

Disabling UAC Virtualization seems to have fixed the problem. 禁用UAC虚拟化似乎解决了问题。

See http://code.google.com/p/msysgit/issues/detail?id=320 请参阅http://code.google.com/p/msysgit/issues/detail?id=320

You can begin with a: 您可以从以下开始:

 GIT_TRACE=1

But it may not display much more than your original message regarding this file. 但它可能不会显示有关此文件的原始消息。

The usual cause is some opened editor which wants to reload the files when changed, and that can conflict with git's file manipulations. 通常的原因是一些打开的编辑器想要在更改时重新加载文件,这可能与git的文件操作冲突。
That means: the usual strategy is to repeat your git command after having close as many other applications as you can . 这意味着:通常的策略是 尽可能多地关闭其他应用程序 之后重复你的git命令。

I haven't found anyone describing similar behavior 我没有找到任何描述类似行为的人

See this thread for instance, ot this one , both on Cygwin. 例如,在Cygwin上看到这个线程 ,或者这个
What version of Git are you using (Git on Cygwin, or MSysGit, in a Cygwin session or a Dos session?) 您使用的是什么版本的Git(Cygwin上的Git或MSysGit,在Cygwin会话或Dos会话中?)

你可以尝试sys内部的Filemon

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM