Add ignored config file to git repo as sample

后端 未结 4 1456
-上瘾入骨i
-上瘾入骨i 2021-02-03 11:56

I have an repository for an app that I\'m working on that includes a configuration file. Currently, I distribute with a .dist extension, and have the user rename th

4条回答
  •  爱一瞬间的悲伤
    2021-02-03 12:41

    You can also version and distribute:

    • a .gitattributes files declaring a filter driver (for only 'config.dist')
    • a smudge script which will detect that content and generate the final (and private, as in "non-versioned" config file)

    Now that is bending a bit what a filter driver is about (it is about modifying the content of a file, regardless of its "state", i.e its full path and name). But it can work.
    The .gitattributes would contain:

    config.dist  filter=generateConfig
    

    alt text

    And you can register your smudge script (applied during the checkout step when creating/updating the working directory) like:

    git config --global filter.generateConfig.smudge /path/to/generateConfig
    

提交回复
热议问题