git 隐藏修改后的文件?

git stash leaving modified files?

我在尝试隐藏更改时遇到了一些奇怪的行为。我不是 git 专家,所以我希望有人能对此有所启发:

  1. 在最新的分支上,我修改了一个跟踪文件。 git状态显示已修改
  2. git 存储(响应“保存的工作目录和索引状态 WIP on...”
  3. git 状态仍然显示文件已修改,但 git diff(和 git gui)显示没有变化。
  4. git 存储列表显示存储已创建
  5. git stash pop 响应 "error: Your local changes to the following files would be overwritten by the merge:"

3 点的行为对我来说毫无意义。它最近才开始发生。我已经使用 stash/stash pop 几个月了,没有任何问题。

我想知道我的本地工作副本是否有问题,所以我重新克隆但得到了相同的行为。

是我的 GIT 安装坏了,还是我遗漏了什么?

附加信息:

git 配置-l:

core.symlinks=true
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
diff.astextplain.textconv=astextplain
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
core.editor='C:\Program Files (x86)\Notepad++\notepad++.exe' -multiInst -    notabbar -nosession -noPlugin
core.excludesfile=C:\GIT\gitignore\VisualStudio.gitignore
core.editor=notepad
core.fscache=true
core.preloadindex=true
gui.fontdiff=-family Consolas -size 10 -weight normal -slant roman -    underline 0 -overstrike 0
gui.recentrepo=C:/GIT/polarisv4
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
user.name=xxxxx
user.email=xxxxxx
difftool.sourcetree.cmd='C:/Program     Files/TortoiseGit/bin/TortoiseGitMerge.exe' "$LOCAL" "$REMOTE"
mergetool.sourcetree.cmd='C:/Program     Files/TortoiseGit/bin/TortoiseGitMerge.exe'  -base:"$BASE" -mine:"$LOCAL" -    theirs:"$REMOTE" -merged:"$MERGED"
mergetool.sourcetree.trustexitcode=true
alias.co=checkout
alias.br=branch
alias.st=status
winupdater.recentlyseenversion=2.15.1.windows.2
credential.helper=manager
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.ignorecase=true

根据 Ortomala Lokni 的建议,我删除了所有全局 git 配置文件 1

问题消失了。我恢复了每个文件,直到问题再次出现,然后摆弄看起来合理的设置。

罪魁祸首是 fscache - 设置为 true 会导致问题。我不知道为什么相同的设置在其他电脑上可以正常工作。

感谢大家的帮助!

正如 DaveW 所说,问题来自 core.fscache=true 设置。这是一个仅 Windows 的设置,它启用文件系统缓存以减轻某些 Windows 文件系统操作的缓慢。这是从提交消息 Win32: add a cache below mingw's lstat and dirent implementations:

中提取的描述

Checking the work tree status is quite slow on Windows, due to slow lstat emulation (git calls lstat once for each file in the index). Windows operating system APIs seem to be much better at scanning the status of entire directories than checking single files.

Add an lstat implementation that uses a cache for lstat data. Cache misses read the entire parent directory and add it to the cache. Subsequent lstat calls for the same directory are served directly from the cache.

Also implement opendir / readdir / closedir so that they create and use directory listings in the cache.

The cache doesn't track file system changes and doesn't plug into any modifying file APIs, so it has to be explicitly enabled for git functions that don't modify the working copy.

此提交消息的最后一句话指出了 OP 问题的原因。