Git:文件重命名
我想将文件夹从“Frameworks
”重命名为“frameworks
”,但 git 不允许我添加新的小写名称。我想它对待文件名不区分大小写,是吗?
git add Frameworks/ -f
没有帮助
I wanted to rename a folder from "Frameworks
" to "frameworks
", but git would not let me add the new lowercase name. I guess it treats filenames case insensitive, does it?
A git add frameworks/ -f
didn't help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试:
“git mv -f foo.txt Foo.txt”
(注意:这不再是从 git 2.0.1 开始需要)ignorecase
设置为 false。但大小写问题(例如在 Windows 上)在 msysgit 问题中进行了描述228(再次强调:这应该现在 - 2014 年 6 月 - 与 git 2.0.1 一起使用)
这篇博文说明了在变基期间 MacO 上的相同问题:
无论如何,记住 git mv 代表什么
:因此,如果
newname
和oldname
冲突,您需要使它们不同(即使只是很短的一段时间),因此git mv foo. txt foo.txt.tmp && git mv foo.txt.tmp Foo.txt
You can try:
"git mv -f foo.txt Foo.txt"
(note: this is no longer needed since git 2.0.1)ignorecase
to false in the config file.But the issue of case (on Windows for instance) is described in the msysgit issue 228 (again: this should now -- June 2014 -- work with git 2.0.1)
This blog post illustrates the same issue on MacOs during a rebase:
Anyhow, remember what git mv stands for:
, so if
newname
andoldname
clash, you need to make them different (even if it is only for a short period of time), hence thegit mv foo.txt foo.txt.tmp && git mv foo.txt.tmp Foo.txt
如果你碰巧在 Github 上托管,你可以使用他们网站上的重命名功能。不得不更换 5 个文件的外壳,发现效果非常好。
If you happen to host on Github, you can use the rename function on their website. Had to change the casing for 5 files and found it worked really well.
我遇到了类似的问题,无法在远程存储库上更改新的文件夹名称(不同的大小写)。我发现最简单的解决方案是将文件移出存储库并提交。触发删除操作。然后重新添加,当我添加时,它带有正确的大小写。
I was having a similar problem and couldn't get a new folder name (different case) to change on remote repos. I found that the easiest solution was just to move the file out of the repo and commit. Triggering a delete action. Then re-add and when I added, it came in with the proper case.