Git is not detecting a file and is not in .gitignore

前端 未结 16 1363
执念已碎
执念已碎 2020-12-05 04:19

I have a file called \"style.css\" and git is not detecting it. It doesn\'t detect it if I delete it either, but it does detect if I change the name of the file. But I need

16条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 04:25

    I had the same problem (components/dashboard/js-dev/training/index.js wasn't being tracked for some reason), so I did the following:

    $ git check-ignore -v components/dashboard/js-dev/training/index.js
    $ (gave me nothing)
    
    $ git check-ignore -v components/dashboard/js-dev/training/
    $ /Users/User/.config/git/ignore:23:    components/dashboard/js-dev/training/
    

    Anyways, I found this to be quite weird, so then I took a look at this file, /Users/User/.config/git/ignore, and this is what it looked like:

    (this is line 1)
    # Automatically created by GitHub for Mac
    # To make edits, delete these initial comments, or else your changes may be lost!
    
    *.DS_Store
    .AppleDouble
    .LSOverride
    
    # Icon must end with two \r
    Icon
    
    # Thumbnails
    ._*
    
    # Files that might appear in the root of a volume
    .DocumentRevisions-V100
    .fseventsd
    .Spotlight-V100
    .TemporaryItems
    .Trashes
    .VolumeIcon.icns
    .com.apple.timemachine.donotpresent
    
    # Directories potentially created on remote AFP share
    .AppleDB
    .AppleDesktop
    Network Trash Folder
    Temporary Items
    .apdisk
    

    And it turns out that line 23 is in fact the one between .com.apple.timemachine.donotpresent and # Directories potentially created on remote AFP share, in other words, it was a completely empty line!

    I tried removing all the extra newlines so my file looked like this:

    # Automatically created by GitHub for Mac
    # To make edits, delete these initial comments, or else your changes may be lost!
    *.DS_Store
    .AppleDouble
    .LSOverride
    # Icon must end with two \r
    Icon
    # Thumbnails
    ._*
    # Files that might appear in the root of a volume
    .DocumentRevisions-V100
    .fseventsd
    .Spotlight-V100
    .TemporaryItems
    .Trashes
    .VolumeIcon.icns
    .com.apple.timemachine.donotpresent
    # Directories potentially created on remote AFP share
    .AppleDB
    .AppleDesktop
    Network Trash Folder
    Temporary Items
    .apdisk
    

    I run git status, and I notice that it's now picking up components/dashboard/js-dev/training/. I run git add components/dashboard/js-dev/training/, and all works fine again.

    Hope this helps someone - this issue got me stuck for an unnecessarily long amount of time.

提交回复
热议问题