简体   繁体   English

Git在不区分大小写的文件系统上添加文件夹的问题

[英]Problems with Git adding folders on a case-insensitive file system

I´m testing Git on Windows to consider using it or not. 我正在Windows上测试Git,以考虑是否使用它。 I´ve just started a new repository, created a .gitignore file and tried to add some folders. 我刚刚启动了一个新的存储库,创建了一个.gitignore文件,并尝试添加一些文件夹。

By now, I´ve faced two problems: 到目前为止,我已经面临两个问题:

  1. I´ve created the .gitignore file using the touch .gitignore command, after that, I´ve tried to add the filters with a cat .gitignore command, but it doesn´t seem to let me add anything, I have to edit the file manually. 我使用touch .gitignore命令创建了.gitignore文件,此后,我尝试使用cat .gitignore命令添加过滤器,但似乎并没有让我添加任何内容,我必须编辑手动归档。

  2. For the test, let´s suppose that I have a folfer named as "Folder", if I use the command git add folder , git seems to add it correctly but if I check it with a git status command, no files have been added, so I have to write it case sensitive, git add Folder and then the git status shows the files of the folder tracked. 对于测试,假设我有一个名为“ Folder”的文件夹,如果我使用命令git add folder ,git似乎正确添加了它,但是如果我用git status命令检查了它,则没有添加任何文件,所以我必须写区分大小写的git add Folder ,然后git status显示所跟踪文件夹的文件。

I´m using Windows and the gitignorecase is set to true. 我正在使用Windows,并且gitignorecase设置为true。

Thanks for your help! 谢谢你的帮助!

Edit: I´ve search a bit about Git with Windows, and the main opinion normally is "Don´t use Git with Windows", so i will look for other DVCS like Mercurial or Bazaar. 编辑:我在Windows上搜索了一些有关Git的信息,通常主要的看法是“不要在Windows上使用Git”,所以我将寻找其他DVCS,例如Mercurial或Bazaar。

Thanks for your answers! 感谢您的回答!

In order to add files to .gitignore, just open it up with a text editor and add them in. If you wanted to add them in from the output of a unix command, you could do something like command >> ~/.gitignore . 为了将文件添加到.gitignore中,只需使用文本编辑器将其打开并添加它们即可。如果要从unix命令的输出中添加它们,则可以执行command >> ~/.gitignore This causes the output of command to be appended to .gitignore. 这将导致命令输出附加到.gitignore。

To answer your second question, core.ignorecase means: 要回答第二个问题,core.ignorecase表示:

If true, this option enables various workarounds to enable git to work better on filesystems that are not case sensitive, like FAT. 如果为true,则此选项启用各种变通办法,以使git在不区分大小写的文件系统(例如FAT)上更好地工作。 For example, if a directory listing finds "makefile" when git expects "Makefile", git will assume it is really the same file, and continue to remember it as "Makefile". 例如,如果目录列表在git期望“ Makefile”时找到“ makefile”,则git将假定它确实是同一文件,并继续将其记住为“ Makefile”。 git-config(1) Manual Page . git-config(1)手册页

This definition does not suggest that you can "add" files with the wrong case and expect it to work. 此定义不建议您以错误的大小写“添加”文件并期望它能正常工作。 In particular you said "add this directory" and the directory-name you gave was not a real directory (differed by case), so it did nothing. 特别是您说了“添加此目录”,并且您给的目录名不是真实目录(视情况而异),因此它什么也没做。

如果文件夹为空,则不会添加任何内容,因为git无法处理空文件夹

  1. cat FILENAME makes cat pipe the contents of a file FILENAME to its standard output, so in this form of invocation, cat cannot be used to modify a file. cat FILENAME使cat将文件FILENAME的内容传送到其标准输出,因此,以这种调用形式,不能使用cat修改文件。

    If you want to use cat to modify the .gitignore file, do 如果要使用cat修改.gitignore文件,请执行

     cat >.gitignore 

    to overwrite that file with whatever you will type to the cat 's standard input (terminating it by entering ^Z ( Ctrl-Z ) on Windows) or 用您将输入到cat的标准输入的任何内容覆盖该文件(在Windows上通过输入^ZCtrl-Z )终止该文件),或

     cat >>.gitignore 

    to append whatever you type into running cat to that file. 附加任何你输入到运行cat到该文件。

    In either case, I'd say trying to use a tool this sharp for a task this simple is a bit odd as you appear to display lack of deep knowledge of the standard Unix toolbox. 无论哪种情况,我都想尝试使用如此锋利的工具完成如此简单的任务有点奇怪,因为您似乎缺乏对标准Unix工具箱的深入了解。 I'd stick to a text editor for now, while learning. 在学习的同时,我现在会坚持使用文本编辑器。

  2. I wonder what gitignorecase is. 我想知道gitignorecase是什么。 The configuration option you need is named core.ignorecase and should be set using a command like 您需要的配置选项名为core.ignorecase ,应使用类似以下的命令进行设置

     git config --add [--local] core.ignorecase true 

    Here's the manual page describing git config and all the standard options it knows. 这是手册页,介绍git config及其已知的所有标准选项。 You can get the local copy of this manual opened in your browser by running 您可以通过运行以下命令在浏览器中打开本手册的本地副本

     git help config 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果系统不区分大小写,则两个表名相同 - Two table names are the same if the system is case-insensitive 关于在不区分大小写的系统 (Windows) 中执行迁移的 SVN 到 Git 迁移问题 - SVN to Git migration question about performing migration in case-insensitive systems (Windows) Shell脚本 - 不区分大小写的匹配 - Shell Script - Case-insensitive matching Mercurial中不区分大小写的文件名处理 - Case-insensitive filename handling in Mercurial 我可以为 Windows 使 Subversion + TortoiseSVN 不区分大小写吗? - Can I make Subversion + TortoiseSVN case-insensitive for Windows? 当不区分大小写的客户端联系和网络服务器时会发生什么? - What happens when a case-insensitive client contacts and webserver? Windows不区分大小写的文件系统中的yGuard模糊代码 - yGuard Obfuscate code in case insensitive file system as Windows 将Java应用程序从不区分大小写的文件系统移动到区分大小写的文件系统 - Moving java app from a case insensitive file system to a case sensitive one 文件夹不区分大小写的Git日志过滤(Windows) - Git log filtering by folder case insensitive (Windows) 由于Windows不区分大小写,因此将混淆的Java代码加载到Eclipse失败 - Load obfuscated Java code to Eclipse failed because Windows is case-insensitive
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM