git stash离开修改过的文件?

问题描述 投票:3回答:2

我试图隐藏更改时会遇到一些奇怪的行为。我不是一个git专家,所以我希望有人可以对此有所了解:

  1. 在最新的分支上,我修改了跟踪文件。 git status显示为已修改
  2. git stash(响应“已保存的工作目录和索引状态WIP on ...)
  3. git status仍然显示文件已修改,但git diff(和git gui)显示没有更改。
  4. git stash list显示已创建存储
  5. git stash pop响应“错误:合并将覆盖对以下文件的本地更改:”

3的行为对我没有意义。它最近才开始发生。我一直在使用stash / stash pop几个月没有问题。

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

我的GIT装置坏了,还是我错过了什么?

附加信息:

  • 在另一台PC上试过这个并且它的行为符合预期,所以它与这个安装有关。
  • 尝试创建一个新的本地仓库,添加并提交1个文件,修改,藏匿。相同的行为
  • 尝试使用CR LF和LF行结尾的文件。相同的行为

git config -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
windows git git-stash
2个回答
2
投票

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

由于lstat仿真速度慢(git为索引中的每个文件调用lstat一次),因此在Windows上检查工作树状态非常慢。 Windows操作系统API在扫描整个目录的状态方面似乎比检查单个文件要好得多。

添加一个使用lstat数据缓存的lstat实现。缓存未命中读取整个父目录并将其添加到缓存中。直接从缓存提供对同一目录的后续lstat调用。

还要实现opendir / readdir / closedir,以便它们在缓存中创建和使用目录列表。

缓存不会跟踪文件系统更改,也不会插入任何修改文件API,因此必须为不修改工作副本的git函数显式启用它。

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


1
投票

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

问题消失了。我恢复了每个文件,直到问题返回,然后摆弄似乎合理的候选人的设置。

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

谢谢大家的帮助!

© www.soinside.com 2019 - 2024. All rights reserved.