git checkout 提示 “error: The following untracked working tree files would be overwritten by checkout” 解决
问题描述
Windows 或者 macOS 操作系统中,文件名是不区分大小写的。对于已经提交到仓库中的文件修改文件名的大小写,然后又用 git rm 命令将老文件从 Git 仓库删除掉,并保存下新的文件,这个时候,再进行切换分支的操作,就会出现这个提示:

复现
# 新建测试文件夹并切换到这个文件夹下面
mkdir test-checkout-error && cd test-checkout-error
# 新建空 Git 仓库
git init
# 新建测试文件 user.php
touch user.php
# 暂存新增文件
git add .
# 发现文件名大小写错误,进行修正
mv user.php User.php
# 再次暂存新增文件
git add .
# 提交到仓库
git commit -m "add user.php and User.php"
# 在当前分支基础上新建分支 dev
git checkout -b dev
# 删除索引中的 user.php
git rm --cached user.php
# 提交到仓库
git commit -m "delete user.php"
# 切换分支,报错
git checkout master error: The following untracked working tree files would be overwritten by checkout:
user.php
Please move or remove them before you can switch branches.
Aborting
分析
由于 Windows 或者 macOS 系统对于文件名是不区分大小写的,如果在 Git 仓库中应用了 ignorecase 的缺少配置 false,那么 Git 会区分文件名的大小写。
解决
在当前项目目录下执行
git config core.ignorecase true
然后再切换分支,进行分支合并等操作之后,再执行
git config --unset core.ignorecase
删除刚才的配置操作。
参考链接:git - The following untracked working tree files would be overwritten by checkout - Stack Overflow
git checkout 提示 “error: The following untracked working tree files would be overwritten by checkout” 解决的更多相关文章
- git解决error: The following untracked working tree files would be overwritten by checkout
在IDEA中进行分支切换时,出现如此错误,导致无法正常切换:error: The following untracked working tree files would be overwritten ...
- Git错误:error: The following untracked working tree files would be overwritten by merge:
[andy@localhost weixin_robot]$ git pull Updating d652d1c..fa05549 error: The following untracked wor ...
- Error pulling origin: error: The following untracked working tree files would be overwritten by...
git在pull时,出现这样的错误的时候,可能非常多人进进行stash.相关stash的请看:Error pulling origin: error: Your local changes to th ...
- Some untracked working tree files would be overwritten by checkout. Please move or remove them before you can checkout. View them
Some untracked working tree files would be overwritten by checkout. Please move or remove them befor ...
- git pull 错误:The following untracked working tree files would be overwritten by merge
错误描述: $ git pull origin alphaFrom https://github.com/shirley-wu/HeartTrace * branch alpha ...
- 错误 error: The following untracked working tree files would be overwritten by merge:README.md
问题类型 相信很多小伙伴在创建新的git仓库后,会选上添加README.md文件,开始我也没太在意,应该也没有什么问题. 但是当我通过git添加远程仓库,给这个仓库上传代码时,出现了如下问题:erro ...
- git更新代码报错,error: The following untracked working tree files would be overwritten by ch
git忽略大小写导致的, git config --add core.ignorecase true
- git clean解决 GIT error: The following untracked working tree files would be overwritten
git clean用法:https://www.cnblogs.com/lsgxeva/p/8540476.html :
- The following untracked working tree files would be overwritten by merge
git pull的时候遇到这样的问题: The following untracked working tree files would be overwritten by merge balabal ...
随机推荐
- Trace 2018徐州icpc网络赛 思维+二分
There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy) ...
- CodeForces Round#480 div3 第2场
这次div3比上次多一道, 也加了半小时, 说区分不出1600以上的水平.(我也不清楚). A. Remove Duplicates 题意:给你一个数组,删除这个数组中相同的元素, 并且保留右边的元素 ...
- 逆向破解之160个CrackMe —— 030
CrackMe —— 030 160 CrackMe 是比较适合新手学习逆向破解的CrackMe的一个集合一共160个待逆向破解的程序 CrackMe:它们都是一些公开给别人尝试破解的小程序,制作 c ...
- HTTPS页面使用CNZZ统计代码,Chrome显示警告怎么办?
很多站长会遇到一个问题,网站加入CNZZ的JS统计代码后,Chrome浏览器出现警告:阻止跨站解析器阻断脚本通过document.write调用(A parser-blocking, cross si ...
- 聚焦Python分布式爬虫必学框架Scrapy 打造搜索引擎视频教程
下载链接:https://www.yinxiangit.com/595.html 目录: 第1章 课程介绍介绍课程目标.通过课程能学习到的内容.和系统开发前需要具备的知识 第2章 windows下搭建 ...
- scrapy-redis分布式爬取猫眼电影
能够利用redis缓存数据库的优点去重来避免数据的大面积冗余 1.首先就是要创建猫眼爬虫项目 2.进入项目内部创建一个爬虫文件 创建完文件之后就是要爬取的内容,我这边以爬取猫眼电影的title和lin ...
- FreeSql (十)更新数据
FreeSql支持丰富的更新数据方法,支持单条或批量更新,在特定的数据库执行还可以返回更新后的记录值. var connstr = "Data Source=127.0.0.1;Port=3 ...
- soap get/post请求
pom.xml依赖: <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactI ...
- charles 禁用Cookies /Block Cookies Settings
本文参考:charles 禁用Cookies 禁用cookies/Block Cookies Settings 功能:阻止发送和接收Cookie 禁用Cookie工具 禁用Cookie工具阻止发送和接 ...
- 会计的疑惑--BigDecimal的秘密
为了提供公司的财务信息化,公司A上线了一套自主研发的财务系统,上班第一天,财务C姐就发现了情况不对:几项支出都对,但支出总和一直为0,赶紧向大老板报告.大老板勃然大怒,责令技术部门今天必须解决,小B负 ...