Is there a way to setup remote-specific .gitignores?

前端 未结 3 1615
醉梦人生
醉梦人生 2020-12-14 16:51

Is there a simple way to setup different .gitignore files for different remotes? I have a repository I push up to both Heroku and Github. I need database.yml for Heroku, b

3条回答
  •  太阳男子
    2020-12-14 17:12

    You should versionned a:

    • database.yml with only variables in it, and
    • a script able to replace those variables by the right values depending on the remote server where that database.yml is deployed.

    Then you use the script as a smudge attribute filter driver:

    smudge content filter

    Each time you will checkout (and create a working tree) on a remote server, the script is executed and will change the variables accordingly, giving you a custom database.yml file.
    If one of the remote does not need that database.yml file, it can still be there, but emptied by the smudge script.

提交回复
热议问题