如何忽略文件的后续修改 [英] How to ignore subsequent modification of a file

查看:76
本文介绍了如何忽略文件的后续修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个database.json,其中应包含Zend项目的数据库凭据,我想知道是否可以使用示例凭据来提交文件,然后忽略它,以避免其他新的提交...

I've a database.json, which should contain the database credential of my Zend project, I wonder if I can commit the file with sample credentials and then ignore it, to avoid other new commits...

这是文件:

{
    "development": {
        "resources": {
            "db": {
                "adapter": "PDO_MYSQL",
                "params": {
                    "host":     "hostname",
                    "username": "username",
                    "password": "password",
                    "dbname":   "dbname"
                }
            }
        }
    }
}

推荐答案

如果您已经跟踪了文件,则无法将其添加到.gitignore-git仍会跟踪修改.您可以使用以下内容:

If you've already tracked a file, adding it to .gitignore won't work - git will still track the modifications. You could use the following:

git update-index --assume-unchanged database.json

然后您可以使用--no-assume-unchanged标志还原该假设:

You can then revert that assumption with the --no-assume-unchanged flag:

git update-index --no-assume-unchanged database.json

作为参考,这是GitHub在此问题上必须说的话.

这篇关于如何忽略文件的后续修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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