现象描述
(注意数据备份)
一个项目由submodule 方式组成了一个主仓库,当在主仓库中修改了多个submodule 的version,同时也修改了一些非submodule 的文件内容。在git add ,git commit ,git push 都成功后,想切换到某个branch(A) 的时候,报出错误error: The following untracked working tree files would be overwritten by checkout。但是 git status发现也没有修改项。
后来发现,可以切换到另一些branch。
解决过程
1.新建一个本地repo(A),从之前push成功的远端repo pull 下来,与报错The following untracked working tree files would be overwritten by checkout 的仓库(B)进行对比,发现内容一致,说明本地内容的确成功上传到了远端。
2.尝试使用git --cached git clean -d -fx
-x means ignored files are also removed as well as files unknown to git.
-d means remove untracked directories in addition to untracked files.
-f is required to force it to run.
没有任何效果
3.后发现为修改文件的时候大小写被修改,使用命令
git config core.ignorecase true 后成功解决该问题。文章来源:https://www.toymoban.com/news/detail-523389.html
文章来源地址https://www.toymoban.com/news/detail-523389.html
到了这里,关于【Git】error: The following untracked working tree files would be overwritten by checkout的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!