Git 如何不包含要提交的特定文件

Git how to not include specific file(s) to commit

我试图不包括一些要提交的文件。例如,我不希望以下文件中的任何更改包含在提交中:

bootstrap/start.php

所以我将它们包含在 .gitignore 中,如下所示:

/bootstrap/compiled.php
/bootstrap/start.php
/vendor
composer.phar
composer.lock
.env.local.php
.env.php
.DS_Store
Thumbs.db.idea
.idea/
/public/dbase
/public/user_images
/app/config/lenovo

但是当我 运行 git status 我仍然收到这条消息:

On branch master
Your branch is up-to-date with 'origin/master'.

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:   .gitignore
    modified:   bootstrap/start.php

no changes added to commit (use "git add" and/or "git commit -a")

怎么做?谢谢

bootstrap/start.php 已被 git 跟踪。

来自 git忽略文档 "A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below for details."

试试这个。

git update-index --assume-unchanged bootstrap/start.php