[英]I am contributing to an repository but " fatal: will not add file alias " is been shown while commit
As the problem is while commit,由于问题是在提交时,
fatal: will not add file alias 'src/Components/Button.js' ('src/components/Button.js' already exists in index)致命:不会添加文件别名 'src/Components/Button.js'('src/components/Button.js' 已存在于索引中)
The above error shows up, as haven't even opened the file and is working fine.出现上述错误,因为甚至没有打开文件并且工作正常。
Read the text carefully and closely:仔细阅读原文:
fatal: will not add file alias 'src/Components/Button.js' ('src/components/Button.js' already exists in index)
致命:不会添加文件别名 'src/Components/Button.js'('src/components/Button.js' 已存在于索引中)
(note: I had to retype this, because you used an image instead of cutting-and-pasting text; please read the How do I ask a good question? help page). (注意:我不得不重新输入,因为您使用的是图像而不是剪切和粘贴文本;请阅读如何提出一个好问题?帮助页面)。
Perhaps this might help:也许这可能会有所帮助:
src/Components/Button.js
src/components/Button.js
Can you see the difference between two letter c
-s here?你能看出这里两个字母
c
-s 之间的区别吗? One is UPPERCASE and one is lowercase .一种是大写,一种是小写。
To Git , these are two different file names .对于Git 来说,这是两个不同的文件名。
To your operating system , these are the same file name .对你的操作系统来说,这些是相同的文件名。
Git can easily store both files. Git 可以轻松存储这两个文件。 But if you make it do that, you won't be able to work with this repository any more —or at least, not in a sensible way, with this particular commit.
但是如果你让它这样做,你将无法再使用这个存储库——或者至少,不是以一种明智的方式,使用这个特定的提交。 Git is carefully keeping you from shooting yourself in the foot .
Git 小心翼翼地防止您射中自己的脚。
Because your system doesn't distinguish between uppercase and lowercase in file and folder names, but Git does, you must be particularly careful when working with a repository that uses MixedCapItALIzaTIOn in file names for whatever crazy reason.因为您的系统不区分文件名和文件夹名中的大写和小写,但 Git 会区分,所以无论出于何种疯狂原因,在使用在文件名中使用 MixedCapItALIZATION 的存储库时,您都必须特别小心。 You should do one or more of the following before proceeding:
在继续之前,您应该执行以下一项或多项操作:
Switch to a system that does think these are different file names.切换到确实认为这些是不同文件名的系统。 The problem is now gone: Git and your OS agree that
src/Components/Button.js
and src/components/Button.js
are two completely different files, and it's easy to store and work with both.问题现在不存在了:Git 和您的操作系统都同意
src/Components/Button.js
和src/components/Button.js
是两个完全不同的文件,并且很容易存储和使用这两个文件。
Figure out why, despite Git's thinking that files should be named src/Components/*
, your actual checkout has them as src/components/*
.弄清楚为什么,尽管 Git 认为文件应该命名为
src/Components/*
,但您的实际检出将它们命名为src/components/*
。 Perhaps you should rename your components
folder to Components
.也许您应该将您的
components
文件夹重命名为Components
。
Dedicate yourself to stamping out this particular craziness: why do we have uppercase and lowercase in the first place?致力于消除这种特殊的疯狂:为什么我们首先要使用大写和小写? Invent a time machine, go back in time to the invention of alphabets, and make sure the mistake never happens in the first place.
发明一台时光机,回到字母表的发明时代,并确保错误永远不会发生。 😀
😀
Convert your software so that everything everywhere always uses lowercase whenever possible, so that the problem never occurs.转换您的软件,以便任何地方的所有内容都尽可能使用小写字母,这样问题就不会发生。 (YOU COULD USE ALL UPPERCASE, BUT THIS FEELS VERY SHOUTY.)
(您可以使用所有大写字母,但这感觉非常刺耳。)
This whole area of file name craziness in certain OSes is a minefield.某些操作系统中文件名的整个区域是一个雷区。 Watch out!
小心!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.