search

Home  >  Q&A  >  body text

Git是否可以忽略对已经commit过的文件的变更?

比如config.yml我已经commit了。 然后修改了config.yml,但对此文件的修改不希望再commit。

PHP中文网PHP中文网2801 days ago601

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-21 11:19:46

    To ignore all changes

    git reset --hard
    

    If you just ignore a single file

    git checkout filename.txt
    

    sry, I misinterpreted it

    You can omit the config.yml.example 加入版本库,然后将 config.yml.gitignore.

    When configuration is enabled, cp config.yml.example config.yml 即可,然后对于 config.yml updates will not be committed.

    reply
    0
  • 阿神

    阿神2017-04-21 11:19:46

    Just put it directly in .gitignore 文件里面屏蔽掉 config.yml. What has been committed before will not change, and Git will automatically ignore the modification to this file in the future.

    reply
    0
  • Cancelreply