为什么git忽略我更改的文件? [英] Why is git ignoring my changed file?

查看:130
本文介绍了为什么git忽略我更改的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对git工作目录中的文件进行了任意更改。



git status 无法识别文件已更改。

git add / path / to / file 不起作用。



git add -f / path / to / file 不起作用。

git status / path / to / file 显示文件与'要提交的更改'存储桶一样。



我删除了我的.gitignore文件,只是为了确保。没有改变任何上述行为。



我完成了 git reset --hard ,重做了我的更改。

这里可能会发生什么?

解决方案

为什么Git会忽略一个文件有两个一般原因: gitignore 子模块



更具体地说,当< git add 时,以下情况会导致Git忽略文件。 code>'被调用:


  1. 该文件与 $ GIT_DIR / exclude

  2. 该文件与回购库内的 .gitignore 文件中的模式相匹配。

  3. 该文件匹配特定于用户的 .gitignore 文件中的模式(由< git config --global core.excludesfile <

    $ b

  4. 该文件是子模块的一部分。更多信息可以在另一个SO问题中找到:



    无法跟踪Git子模块中的文件


    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/to/file has no effect.

    git add -f /path/to/file has no effect.

    git status /path/to/file shows the file as in the 'changes to be committed' bucket.

    I removed my .gitignore file, just to be sure. No change to any of the above behaviors.

    I have done git reset --hard, re-made my change. No change to any of the above behaviors.

    What could be going on here?

    解决方案

    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

    这篇关于为什么git忽略我更改的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆