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 ...
随机推荐
- Codeforces Round #480 (Div. 2)980C Posterized+分组类贪心
传送门:http://codeforces.com/contest/980/problem/C 参考 题意:给定n个数字,每个数在0~256间,现在给至多连续k的数分为一组,给出字典序最小的答案. 思 ...
- Increasing heap size while building the android source code on Ubuntu 15.10
http://stackoverflow.com/questions/34940793/increasing-heap-size-while-building-the-android-source-c ...
- MPA JS CSS预处理方案
1.WebPack 添加配置文件webpack.config.js,直接在当前目录运行 webpack. var basepath = '/root/webapps/happ'; var glob = ...
- 「每日五分钟,玩转JVM」:对象内存布局
概览 一个对象根据不同情况可以被划分成两种情况,当对象是一个非数组对象的时候,对象头,实例数据,对齐填充在内存中三分天下,而数组对象中在对象头中多了一个用于描述数组对象长度的部分 对象头 对象头分为两 ...
- 【2】KNN:约会对象分类器
前言 这是一个KNN算法的应用实例,参考<机器学习实战>中的datingTestSet2.txt的数据集. 可以通过对不同约会对象的特征进行分析然后自动得出以下三种结论: 不喜欢的 有点魅 ...
- java 代理模式-静态代理与动态代理
最近在研究SpringAOP,当然要学习AOP就要知道这么健硕.强大的功能的背后究竟隐藏着怎样不可告人的“秘密”?? 接下来就是查阅了许多资料详细的研究了一下Java的代理模式,感觉还是非常非常重要的 ...
- 详解JAVA字符串类型switch的底层原理
基础 我们现在使用的Java的版本,基本上是都支持String类型的.当然除了String类型,还有int.char.byte.short.enum等等也都是支持的.然而在其底部实现中,还是基于 整型 ...
- VUE中CSS样式穿透
VUE中CSS样式穿透 1. 问题由来 在做两款H5的APP项目,前期采用微信官方推荐的weui组件库.后来因呈现的效果不理想,组件不丰富,最终项目完成后全部升级采用了有赞开发的vant组件库.同时将 ...
- docker 搭建小型的node开发环境。
选择daocloud的镜像源----快.不多说 镜像的准备: docker pull docker.io/node 下载node镜像 docker pull daocloud.io/nginx 下载n ...
- Unity3D_07_日志、文本打印
1.Debug.Log(“hello”); 2.打开控制台查看日志:ctrl+shift+c 3.输出一个位置的坐标(需要转换成字符串.ToString()) Vector3 worldPositio ...