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

前端 未结 16 1357
执念已碎
执念已碎 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:21

    Quitting the GitHub app worked for me.

    Symptoms: My repo is on google file stream. I could only see modified files when running git status but the GitHub app showed all changes.

    0 讨论(0)
  • 2020-12-05 04:24

    Extra note, I ran into this problem and found that changes to files weren't being added to commits. Nothing seemed to work, except Right clicking the project, and doing:

    Team > Advanced > No assume unchanged

    0 讨论(0)
  • 2020-12-05 04:24

    I also ran into this issue and it seems to be a problem with EGit plugin for Eclipse. Like @user1655478 said in previous comment, selecting the project in the projects view, performing a right click and selecting "Team > Advanced > No assume unchanged" fixed the problem for me.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-05 04:25

    this happened to me when I was working on a branch I had just created called 'am'. I got on another dev station and couldn't see the file I added to the branch. In order to see the file I ran the following command

    git checkout am
    git branch --set-upstream-to=origin/am
    git pull
    

    after the pull all the changes came down

    0 讨论(0)
  • 2020-12-05 04:35

    Use git check-ignore command to debug your gitignore file (exclude files).

    In example:

    $ git check-ignore -v config.php
    .gitignore:2:src    config.php
    

    The above output details about the matching pattern (if any) for each given pathname (including line).

    So maybe your file extension is not ignored, but the whole directory.

    The returned format is:

    <source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
    

    Or use the following command to print your .gitignore in user and repo folder:

    cat ~/.gitignore $(git rev-parse --show-toplevel)/.gitignore $(git rev-parse --show-toplevel)/.git/info/exclude
    

    Alternatively use git add -f <path/file> which allows adding otherwise ignored files.

    See: man gitignore, man git-check-ignore for more details.

    0 讨论(0)
提交回复
热议问题