报错:Git上传代码报错 will not add file alias already exists in index

简介: 报错:Git上传代码报错 will not add file alias already exists in index

Git上传代码报错 will not add file alias already exists in index。有同学遇到了这个错误。


过程:

有个文件名的大小写写错了,然后修改后重新上传一下代码,就报这个错了,说不能修改。


比如以前是xxx.java文件,提交上去了,现在需要改成Xxx.java文件。


原因:

Git默认是不区分大小写的,所以你需要设置为区分大小写。


解决方法【推荐】


直接设置Git,在命令行中执行:


git config --global core.ignorecase false


或者,修改项目下的 git 配置文件 .git/config

[core]
  ignorecase = false


然后恢复一下文件,需要进入到文件目录,不然要加上文件的路径,然后add一下就可以了,当然最后也可以提交一下:

git reset xxx.java
git add Xxx.java
git commit


如果想合并上一次,则在提交的时候用:

git commit --amend


不要使用IDEA上传,因为测试过发现无法生效,只好用命令行提交了。

也可以删除掉缓存,再重新用命令行提交也可以(xxxx.java为文件):

git rm --cached xxxx.java -r


当然,除此之外,你也可以修改一下代码的名称,换成其他的,再提交也行。

相关文章
|
4月前
|
安全 开发工具 git
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
485 5
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
|
7月前
|
算法 安全 网络安全
git clone操作报错diffie-hellman-group1-sha1的解决方案
在处理这一问题时,需要确保了解相关操作的安全影响。`diffie-hellman-group1-sha1`算法被认为是不够安全的,这是因为随着计算能力的提高,`SHA-1`算法可以在合理的时间内被破解,而且其对应的 `1024位`Diffie-Hellman组也可能不够强大。因此,在确保Git操作的同时,也要考虑提升安全性的长期解决办法。强烈推荐与管理员或相关技术支持团队合作,升级和加强服务器端的安全配置。
182 12
|
8月前
|
网络协议 开发工具 git
解决 git 报错 “fatal: unable to access ‘https://github.com/.../.git‘: Recv failure Connection was rese
在使用 Git/Git小乌龟 进行代码管理的过程中,经常会遇到各种各样的问题,其中之一就是在执行 git clone 或 git pull 等操作时出现 “fatal: unable to access ‘https://github.com/…/.git’: Recv failure Connection was reset” 的报错。这个问题通常是由网络连接问题或代理设置不正确导致的。在我的个人使用经验中,我亲自尝试了四种方法,它们都能够有效地解决这个报错。个人比较推荐方法二。
5316 1
|
11月前
|
开发工具 git 索引
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
227 21
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
|
10月前
|
Shell 开发工具 git
解决git bash报错:在仓库中检测到可疑的所有权
总的来说,解决“在仓库中检测到可疑的所有权”的报错,关键在于理解和调整文件或目录的所有权。只要我们正确地设置了文件或目录的所有权,那么我们就可以避免这种问题,让Git Bash正常工作。
386 22
|
12月前
|
开发工具 git
git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡
git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡
897 3
git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡
|
存储 开发工具 数据安全/隐私保护
git报错The project you were looking for could not be found 解决方式
git报错The project you were looking for could not be found 解决方式
3925 1
|
Shell 网络安全 开发工具
fatal: unable to access 'https://github.com/wolfcw/libfaketime.git/': Encountered end of file
fatal: unable to access 'https://github.com/wolfcw/libfaketime.git/': Encountered end of file
|
开发工具 git
git add . 的时候遇到warning: LF will be replaced by CRLF in ...... 解决办法
今天刚换了一台电脑,在使用Git的时候遇到了这个问题: 输 入 git add * 后出现 warning: LF will be replaced by CRLF in ...... The file will have its original line endings in your working directory. 解决方法: git config --glo
2681 0
|
5月前
|
开发工具 git
Git版本控制工具合并分支merge命令操作流程
通过以上步聚焦于技术性和操作层面指南(guidance), 可以有效管理项目版本控制(version control), 并促进团队协作(collaboration).
1064 15