git - 错误 : The following untracked working tree files would be overwritten by checkout

标签 git git-pull git-status

当我执行 git status 时,它说 nothing to commit, working directory clean

然后我执行 git pull --rebase,它说:

First, rewinding head to replay your work on top of it...
error: The following untracked working tree files would be overwritten by checkout:
    includes/resources/moduledata/12/_Fr4_02_Invention_IPA_SR_la-Fête.pdf
Please move or remove them before you can switch branches.
Aborting
could not detach HEAD

执行 git pull origin master 时出现类似错误

 * branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
    includes/resources/moduledata/12/_Fr4_02_Invention_IPA_SR_la-Fête.pdf
Please move or remove them before you can merge.
Aborting

我的.gitignore 文件:

→ cat .gitignore 
.htaccess
bower_components/

这个文件一直出现,当我从文件系统中删除它时,git 会说我删除了这个文件,而在其他消息中,它说它未被跟踪。怎么可能同时取消跟踪和跟踪呢?

最佳答案

这也可能由于文件名的大小写更改而发生。我遇到了同样的问题,这就是为我解决的问题。

git config core.ignorecase true

适用于 Mac 或 PC。

替代解决方案:The following untracked working tree files would be overwritten by checkout

关于git - 错误 : The following untracked working tree files would be overwritten by checkout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25392771/

相关文章:

git - 为什么我的 git 历史看起来像一棵圣诞树?

git - 无法使用 git add 添加文件

git 克隆 ssh 权限被拒绝

node.js - 使用 Github 个人访问 token 构建 Jenkins npm

git - 你让我 pull 而没有告诉我你想 merge 到哪个分支

即使使用 --no-edit,Git Pull 也会打开 VIM

git - 如何让 git 忽略 .gitignore 中的忽略

git - 为什么 'git commit' 不保存我的更改?

git undo merge and add for 单个文件

git - 在服务器上使用 Git 进行访问控制(不是 gitosis 或 gitolite)