Git 显示状态干净,但签出抱怨覆盖未跟踪的文件

Int*_*ted 5 git case-sensitive

首先:

git status 
Run Code Online (Sandbox Code Playgroud)

结果是干净的。

第二

 git checkout fb/booking_interaction
 error: The following untracked working tree files would be overwritten by checkout:
 web/sites/all/modules/contrib/ckeditor/images/buttons/blockQuote.png
Run Code Online (Sandbox Code Playgroud)

第三,尝试清除未跟踪的文件。在指定目录下:

git clean -f .
Run Code Online (Sandbox Code Playgroud)

同样,没有任何更改,并且 git checkout 失败。

问题是什么?

Int*_*ted 4

该问题是由于文件系统区分大小写造成的。

看着问题。文件清单:

> ls
imageButton.png
imagebutton.png
Run Code Online (Sandbox Code Playgroud)

检查 git 是否设置为区分大小写

> vi .git/config
ignorecase = false
Run Code Online (Sandbox Code Playgroud)

本机区分大小写。进行更改的机器也一定如此。

> git log
removeformat.png - renamed from removeFormat.png. 
Run Code Online (Sandbox Code Playgroud)

由于我更改了ignorecase,git status 现在显示了更改。

> git status

Untracked files:
(use "git add <file>..." to include in what will be committed)

blockQuote.png
bulletedList.png
Run Code Online (Sandbox Code Playgroud)

Git clean 也按预期工作

git clean -f .
Removing blockQuote.png
Removing bulletedList.png
Run Code Online (Sandbox Code Playgroud)

我可以毫无问题地检查其他分支。

  • 遇到同样的问题,这并没有解决它。 (2认同)