我如何调试git错误:"当没有任何东西可以存储时,"对checkout覆盖以下文件的本地更改?

Tim*_*lis 10 git git-svn

我正在使用git-svn,而我正在尝试运行git svn rebase.

我收到错误:

Your local changes to the following files would be overwritten by checkout:
<filename>
Please, commit your changes or stash them before you can switch branches.
Run Code Online (Sandbox Code Playgroud)

我以前运行过git update-index --assume-unchanged <filename>,并对文件进行了更改,但我现在已经git update-index --no-assume-unchanged <filename>开始摆脱它了.

git status没有报告任何变化,并git stash说没有什么可以藏匿.

我已经检查过该文件不在.gitignore.git/info/exclude

如何进一步调试此问题?

小智 12

我遇到了这个问题,Tim的回答帮助我找到了解决方案.

过去我跑了:

git update-index --assume-unchanged index.php
Run Code Online (Sandbox Code Playgroud)

问题

在远程对另一个分支进行一系列更改后,我在尝试在本地切换时收到覆盖警告.

git checkout other-branch

error: Your local changes to the following files would be overwritten by checkout:
index.php
Please, commit your changes or stash them before you can switch branches.
Aborting
Run Code Online (Sandbox Code Playgroud)

藏匿不起作用.

git stash save --keep-index
No local changes to save
Run Code Online (Sandbox Code Playgroud)

解决方案

git update-index --no-assume-unchanged index.php
git add index.php
git commit
Run Code Online (Sandbox Code Playgroud)

之后.

git checkout other-branch
Run Code Online (Sandbox Code Playgroud)

成功!


Tim*_*lis 11

事实证明我skip-worktree有点设置,所以我需要运行

git update-index --no-skip-worktree <filename>
Run Code Online (Sandbox Code Playgroud)

我通过跑步找到了这个

git ls-files -v | grep "^[^H]"
Run Code Online (Sandbox Code Playgroud)

(或git ls-files -v | where { $_ -match "^[^H]"}使用Windows Powershell)

打字git help ls-files解释了输出的含义.