简体   繁体   中英

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

I´m testing Git on Windows to consider using it or not. I´ve just started a new repository, created a .gitignore file and tried to add some folders.

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.

  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.

I´m using Windows and the gitignorecase is set to 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.

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 . This causes the output of command to be appended to .gitignore.

To answer your second question, core.ignorecase means:

If true, this option enables various workarounds to enable git to work better on filesystems that are not case sensitive, like 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-config(1) Manual Page .

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.

    If you want to use cat to modify the .gitignore file, do

     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 >>.gitignore 

    to append whatever you type into running cat to that file.

    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. I'd stick to a text editor for now, while learning.

  2. I wonder what gitignorecase is. The configuration option you need is named core.ignorecase and should be set using a command like

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

    Here's the manual page describing git config and all the standard options it knows. You can get the local copy of this manual opened in your browser by running

     git help config 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM