我更改了目录的大小写,但 Git 似乎没有注意到它
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6899582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I change the capitalization of a directory and Git doesn't seem to pick up on it
提问by dan
I'm developing a project on OS X Lion that is under Git version control. I had these lowercase directories and then later capitalized them (e.g. emailaddresses => EmailAddresses), but Git doesn't seem to recognize the change. It still thinks the directories are lowercase when I run git ls-files
and other commands.
我正在 OS X Lion 上开发一个受 Git 版本控制的项目。我有这些小写的目录,然后将它们大写(例如 emailaddresses => EmailAddresses),但 Git 似乎无法识别更改。当我运行git ls-files
和其他命令时,它仍然认为目录是小写的。
Is this harmless, or should I do something else to get Git to pick up on this change?
这是无害的,还是我应该做其他事情让 Git 了解这个变化?
回答by Taran
You can tell git to take account of the case by running
您可以通过运行告诉 git 考虑这种情况
git config core.ignorecase false
git config core.ignorecase false
回答by Paul R
You're probably using case insensitive (but case preserving) HFS+. I usually work round this like so:
您可能正在使用不区分大小写(但保留大小写)的 HFS+。我通常像这样解决这个问题:
$ git mv somename tmpname
$ git mv tmpname SomeName
回答by David Manpearl
How to git mv on Mac Case-Sensitively
如何在 Mac 上 git mv 区分大小写
This is happening because Mac OS X implements case preserving and case insensitivity features that are intended to help you.
发生这种情况是因为 Mac OS X 实现了旨在帮助您的大小写保留和不区分大小写功能。
Although the double rename suggestions in the other answer will work, I recommend the use of '--force' for a best practice result:
尽管另一个答案中的双重重命名建议会起作用,但我建议使用“--force”以获得最佳实践结果:
$ git mv --force somename SomeName
Note: if you try without the force option, git will barf on you like this:
注意:如果你尝试不使用 force 选项,git 会像这样对你吐口水:
$ git mv somename SomeName
$ fatal: destination exists, source=somename, destination=SomeName
In the above example, the git command fails and no files are changed in the filesystem or in git's index.
在上面的例子中,git 命令失败并且文件系统或 git 的索引中没有文件被更改。
回答by pooamlairaj
Try to change git config option core.ignorecase to false in your .gitconfig file.
尝试将 .gitconfig 文件中的 git 配置选项 core.ignorecase 更改为 false。
回答by Renil Babu
The following steps helped me resolve the issue:
以下步骤帮助我解决了这个问题:
Rename the folder to
temp
:mv Folder temp // It will rename your Folder to temp
Stage and commit:
git add . git commit -m "Temp"
Rename
temp
folder to your choice:mv temp folder // It will rename temp folder to the name of your choice(folder) git add . git commit -m "Folder Fixed"
将文件夹重命名为
temp
:mv Folder temp // It will rename your Folder to temp
阶段和提交:
git add . git commit -m "Temp"
将
temp
文件夹重命名为您的选择:mv temp folder // It will rename temp folder to the name of your choice(folder) git add . git commit -m "Folder Fixed"
Done - You can now push.
完成 - 您现在可以推送了。
回答by Gapur Kassym
If you do git mv AAA aaa
or git mv -f AAA aaa
, it will not be work and you will have error fatal: renaming 'AAA' failed: Invalid argument
.
如果你这样做git mv AAA aaa
或git mv -f AAA aaa
,它不会工作,你会出错fatal: renaming 'AAA' failed: Invalid argument
。
Because AAA
and aaa
are ONE SAMEfolder/file on case-insensitive file systems, move AAA
to aaa
means move AAA
as aaa/AAA
.
因为AAA
和在不区分大小写的文件系统上aaa
是一个相同的文件夹/文件,所以移动AAA
到aaa
意味着移动AAA
为aaa/AAA
.
So you should do
所以你应该做
git mv AAA aaa.1
git mv aaa.1 aaa
I hope it will be helpful for you.
我希望它会对你有所帮助。
回答by Taha
You can also do this manually without using GIT commands. Inside the .git
folder, simply delete the folder with the name you want i.e SomeName
. And then rename the folder somename
to SomeName
. More details at : How to fix folder name set to uppercase and git convert to lowercase
您也可以在不使用 GIT 命令的情况下手动执行此操作。在.git
文件夹内,只需删除具有您想要的名称的文件夹,即SomeName
. 然后将文件夹重命名somename
为SomeName
. 更多详细信息:如何将文件夹名称设置为大写并将 git 转换为小写
回答by giapnh
The reason for this is that LINUX-based OS or macOS ignore case sensitive for file/folder name. We need to resolve this problem by the below steps
原因是基于 LINUX 的操作系统或 macOS 忽略文件/文件夹名称区分大小写。我们需要通过以下步骤来解决这个问题
For Exp, you want to change folder name from Base to base
1. mv Base base2
2. git add . && git commit -m "Fix folder name problem (wip)"
3. mv base2 base
4. git add . && git commit -m "Fixed folder name problem"
回答by Bruno Cunha
None of these solutions worked for me. SourceTree was always creating my branch with a different case from what I wanted. So how I solved it was:
这些解决方案都不适合我。SourceTree 总是使用与我想要的不同的案例来创建我的分支。所以我是如何解决的:
1 - Look at your git files on finder. You can do it by typing this on the terminal:
1 - 在 finder 上查看您的 git 文件。您可以通过在终端上输入以下内容来完成:
- `defaults write com.apple.finder AppleShowAllFiles TRUE`
- `killall Finder`
2 - Relaunch the finder and go to your project directory
2 - 重新启动查找器并转到您的项目目录
3 - Now just change your folder name, let's say from Feature to feature . And there you go.
3 - 现在只需更改您的文件夹名称,让我们说从 Feature 到 feature 。你去吧。