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

前端 未结 16 1358
执念已碎
执念已碎 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条回答
  • I had a similar issue and solved it.

    I was getting this error message when running the git add command:

    The following paths are ignored by one of your .gitignore files:
    <file>
    Use -f if you really want to add them. 
    fatal: no files added
    

    So I tried to force Git to solve the issue for me by adding a -f to the git add command. This would normally force Git to adjust the .gitignore file and you will then be able to see the required change or problematic setting.

    In my particular case there seemed to be some weird issue with the newline at the end of the .gitignore file. Here how Git fixed the problem:

    -RemoteSystemsTempFiles
    +RemoteSystemsTempFiles
    \ No newline at end of file
    
    0 讨论(0)
  • 2020-12-05 04:36

    The file could also be listed in .git/info/exclude, and there’s the option core.excludesfile to watch, too.

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

    In my case I check my .gitignore_global, I found all my swift files ignored, I just removed the line *.swift and git recognized my ones.

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

    Another note, probably a rare case but I had this problem. I moved some files that were already tied to a repo from one directory to another, copy/paste style.

    Along with it came the .git folder, which prevented git from detecting the folder.

    So my folder structure was this, with git not detecting Folder 2 even though the repo was set for Original Project 1:

    --Original Project 1
        --.git
        --Folder 1
        --Folder 2
             --.git
             --Many other files/folders
    

    Deleting the child .git folder solved my problem.

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

    first check in your git repository to make sure that the file isn't there, sometimes capitalized letters can mess up a file being recognized but won't be recognized as a change, especially in a file extension like .JPG

    (for some reason this happened to me although the file was saved the same as the others the extension was capitalized only on one and wouldn't appear on the site)

    'if' this is the problem check 'show file name extensions' in relevant folder, rename file as something else with lower case extension, git add and commit and then rename it as originally wanted but keeping the lower case extension, because of the more obvious change it will be rewritten and not ignored

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

    Apart from the the gitignore and other places to check for ignore patterns, check if you had run git update-index --assume-unchanged or git update-index --skip-worktree. If so, unset them.

    Make sure that there is not some weirdness in the repo or parent of the file under concern whereby it has a .git of its own.

    Try doing a clone of your repo and see if you see the same in the cloned one. If so, try cloning onto a different machine / VM and check. That will give you some idea of what's going wrong where.

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