在 Git 中更改文件名的大小写 [英] Changing capitalization of filenames in Git
问题描述
我正在尝试将文件重命名为与以前不同的大小写:
git mv src/collision/b2AABB.js src/collision/B2AABB.js致命:目标存在,源=src/collision/b2AABB.js,目标=src/collision/B2AABB.js
如您所见,Git 对此表示不满.我也尝试仅使用普通的旧 mv
命令重命名,但 Git 不接受重命名(作为重命名 或 作为新的未跟踪文件).>
如何将文件更改为具有相同名称的不同大小写?我在 Mac OS X v10.7.3 (Lion) 和 Git 1.7.9.1 上使用 Z shell (zsh) 4.3.15.
Starting Git 2.0.1(2014 年 6 月 25 日),git mv
将仅适用于不区分大小写的操作系统.
参见 commit baa37bf 来自 大卫·特纳 (dturner-tw
).
mv
:允许重命名以修复不区分大小写的文件系统的大小写
"git mv hello.txt Hello.txt
"在不区分大小写的文件系统上总是触发destination already exists
";错误,因为从文件系统的角度来看,这两个名称指的是相同的路径,并且需要用户提供--force
";更正索引中记录的路径大小写以及下次提交时.
检测这种情况并在不需要--force
"的情况下允许它.
git mv hello.txt Hello.txt
正常工作(不再需要 --force
).
另一种选择是:
git config --global core.ignorecase false
并直接重命名文件;git 添加并提交.
它在 CMD 中确实有效.它可能会在 git bash(在 Windows 上)会话中失败(请参阅 Louis-Caron 的 答案)
I am trying to rename a file to have different capitalization from what it had before:
git mv src/collision/b2AABB.js src/collision/B2AABB.js
fatal: destination exists, source=src/collision/b2AABB.js, destination=src/collision/B2AABB.js
As you can see, Git throws a fit over this. I tried renaming using just the plain old mv
command as well, but Git doesn't pick up the rename (as a rename or as a new untracked file).
How can I change a file to have a different capitalization of the same name? I am on Mac OS X v10.7.3 (Lion) with Git 1.7.9.1 using Z shell (zsh) 4.3.15.
Starting Git 2.0.1 (June 25th, 2014), a git mv
will just work on a case-insensitive OS.
See commit baa37bf by David Turner (dturner-tw
).
mv
: allow renaming to fix case on case-insensitive filesystems
"git mv hello.txt Hello.txt
" on a case-insensitive filesystem always triggers "destination already exists
" error, because these two names refer to the same path from the filesystem's point of view and requires the user to give "--force
" when correcting the case of the path recorded in the index and in the next commit.
Detect this case and allow it without requiring "
--force
".
git mv hello.txt Hello.txt
just works (no --force
required anymore).
The other alternative is:
git config --global core.ignorecase false
And rename the file directly; git add and commit.
It does work in a CMD. It might fail in a git bash (on Windows) session (see Louis-Caron's answer)
这篇关于在 Git 中更改文件名的大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!