我在尝试隐藏更改时遇到了一些奇怪的行为。我不是一个git专家,所以希望有人能够解释一下:
- 在最新的分支上,我修改了一个已跟踪的文件。git status显示它已被修改
- git stash(回应“Saved working directory and index state WIP on...”)
- git status仍然显示该文件已被修改,但git diff(和git gui)没有显示任何更改。
- git stash list显示已创建了隐藏
- git stash pop 回应“error: Your local changes to the following files would be overwritten by the merge:”
第3个行为对我来说毫无意义。它最近才开始发生。我已经使用stash/stash pop几个月了,没有问题。
我想知道是否存在本地工作副本问题,因此我重新克隆了一份,但出现了相同的行为。
我的GIT安装有问题,还是我漏掉了什么?
额外信息:
在另一台PC上尝试过,表现如预期,因此与此安装有关。
尝试创建一个新的本地repo,添加&提交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
git stash clear
了吗?请注意,这些条目将受到修剪的影响,可能无法恢复。在使用git stash list
命令之前,请先检查它们。 - Ortomala Loknigit stash
在做完两个提交(索引和工作树)后运行git reset --hard
。如果git reset --hard
使工作树处于修改状态,那么你将会得到这种情况。在某些 CRLF 转换设置下,它确实会这样做,例如当存储在仓库中的文件是只读的,并且具有与当前配置不兼容的行结尾时,现在也在索引中。 - torek