Git: File Rename
我想把一个文件夹从"EDOCX1"〔0〕重命名为"EDOCX1"〔0〕,但git不允许我添加新的小写名称。我想它对文件名不区分大小写,是吗?
一个
您可以尝试:
"git mv -f foo.txt Foo.txt" (注:自git 2.0.1起不再需要)- 在配置文件中将
ignorecase 设置为false。
但是case的问题(例如在Windows上)在msysgit版本228中有描述(再次说明:现在应该——2014年6月——使用git 2.0.1)
there is always an option to set
ignorecase to false in the config file that will force Unix like Git semantics on top of NTFS.
Git supports this behavior but it is not the default - from NTFS point of viewa.txt
andA.txt are the same thing - so Git tries to preserve that as most users would expect
号
As a better workaround, you can
1 git mv foo.txt foo.txt.tmp && git mv foo.txt.tmp Foo.txt, which also changes the case of the file as stored on disk.
号
这篇博客文章说明了在重新平衡期间MacOS上的相同问题:
The default on Mac OS X file systems is that they are case-insensitive.
FFFFFF.gif is the same asffffff.gif .If you delete the file in question, just from the file system, not from the Git index, mind you, you can merge the branch in question, and have it restore the file as if nothing happened.
The steps are pretty simple:
1
2 $ rm file/in/question.gif
$ git merge trunk
号
无论如何,记住git mv代表什么:
1 2 3 | mv oldname newname git add newname git rm oldname |
因此,如果
如果你碰巧在Github上托管,你可以在他们的网站上使用Rename函数。不得不换了5个文件的外壳,发现效果很好。
我遇到了类似的问题,无法在远程回购上更改新的文件夹名(不同的大小写)。我发现最简单的解决方案就是将文件移出repo并提交。触发删除操作。然后重新添加,当我添加时,它与正确的情况一起出现。