Why is git ignoring my changed file?

前端 未结 9 1157
南旧
南旧 2021-02-04 05:22

I make an arbitrary change to a file within my git working directory.

git status does not recognized that the file has changed.

git add /path

相关标签:
9条回答
  • 2021-02-04 05:58

    You check your global git ignore file?

    git config --global --get-all core.excludesfile
    git config --system --get-all core.excludesfile
    

    If either of those return a file as their value, look in that file.

    0 讨论(0)
  • 2021-02-04 05:59

    There are two general reasons why Git will ignore a file: gitignore and submodules.

    To be more specific, the following conditions will cause Git to ignore a file when 'git add' is invoked:

    1. The file matches a pattern in $GIT_DIR/exclude.
    2. The file matches a pattern in a .gitignore file inside the repo.
    3. The file matches a pattern in a user-specific .gitignore file (specified by 'git config --global core.excludesfile').
    4. The file is part of a submodule.

    More info can be found in another SO question:

    Unable to track files within Git submodules

    0 讨论(0)
  • 2021-02-04 06:04

    Check each parent directory from the file in question to the project root for .gitignore files.

    Some projects use several .gitignore files, each in its own directory, instead of a single .gitignore in the root.

    0 讨论(0)
  • 2021-02-04 06:09

    Are you sure that your file is not excluded by some of the .gitignore files in parent directories?

    0 讨论(0)
  • 2021-02-04 06:10

    After you did git add, did you do a commit so it's actually in the repo and can be compared to the (changed) working copy?

    0 讨论(0)
  • 2021-02-04 06:13

    if your file is in the 'Changes to be committed' bucket then git already recognized the change and is going to commit it! Its in the index already. Otherwise it would be in the 'Changed but not updated' bucket.

    :)

    Hope this helps/

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