简体   繁体   English

我正在为存储库做出贡献,但在提交时显示“致命:不会添加文件别名”

[英]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.jssrc/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.

相关问题 在贡献时恢复推送提交中的单个文件 - Revert single file in pushed commit while contributing 为什么我会致命:文件来自Jenkins的存储库 - Why am I getting fatal: file is outside repository from Jenkins 如何在其他目录中的git存储库中添加和提交文件 - How do I add and commit file in a git repository while in different directory 在主存储库中工作时,是否需要手动提交/推送 Git 子模块 SHA? - Do I need to manually commit/push Git submodule SHA while I am working inside the main repository? 当我在git命令提示符下键入“ git add”时,收到致命消息,即不是git存储库。 - I am getting fatal message i.e not a git repository, when I am typing “git add .” in git command prompt. Rake w/Git 说“致命:不会添加文件别名”但我可以手动完成吗? - Rake w/Git says 'fatal: Will not add file alias' but I can do it manually? 尝试提交已经是git init的目录。 收到“致命消息:不是git存储库(或任何父目录)” - Trying to commit a directory that has been git init. Receiving “ fatal: Not a git repository (or any of the parent directories) ” Git 添加不起作用并在我尝试添加文件夹或所有文件时出现致命错误 - Git add is not working and giving fatal error while i am trying to add folder or all the files 如何找到已归档的存储库的提交哈希 - How do I find a commit hash for a repository that has been archived 如何向此 git 别名添加自定义提交消息? - How can I add a custom commit message to this git alias?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM