我有一个 Drupal 多站点并将其克隆到本地进行设置。我已经更改了一些用于数据库访问的设置文件。当我执行 GIT 状态时,我得到...
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: .gitignore
modified: sites/default/settings.php
modified: sites/mysite1/settings.php
modified: sites/mysite2/settings.php
我不想提交这些文件,我希望 GIT 忽略它们。
我已将它们添加到 .gitignore,但仍在跟踪它们。
我试过运行以下......
git update-index --assume-unchanged <file>
但这什么都不做。
我如何告诉 GIT 忽略这些文件?
最佳答案
I have added them to .gitignore but they are still being tracked.
您需要先从索引中删除这些文件 (git rm --cached -- ...
),如果您想保留它们的版本,这不是一个好方法。
而且您冒着错误地提交这些更改的风险。
但是,如果您不这样做,那么这些文件将被忽略。
要在本地忽略它们,您也可以尝试:
git update-index --skip-worktree -- <file>
关于混帐。忽略要提交的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23512499/