为什么 git 仍然指向 .gitignore 文件

  • 本文关键字:gitignore 文件 git git
  • 更新时间 :
  • 英文 :


我在本地存储库上的.gitignore如下所示:

api/includes/utility.php
api/includes/AppSettings.php

当我对上述文件进行更改时,git 似乎希望我跟踪它们并提交,否则不会让我git pull

例如,在git status

# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#   modified:   api/includes/utility.php

我已经阅读了几篇关于 Stack 的类似问题的帖子,但我没有在 .gitignore 中使用通配符。

在这种情况下,文件已被跟踪;在"取消跟踪"之前,它不能真正被忽略。您可以使用git rm --cached api/includes/utility.php"取消跟踪"它。 请注意,这将在其他人的计算机上删除它 当他们执行git pull .

最新更新