Using conditional configuration files with Git

后端 未结 3 1526
小蘑菇
小蘑菇 2020-11-27 07:19

I frequently find myself changing a single variable in my project within Git to connect to a different server while on the Development branch (in JavaScript, so I can\'t use

3条回答
  •  死守一世寂寞
    2020-11-27 07:43

    Sounds like you might be interested in a hook; specifically, look into the post-checkout hook. Basically, you would write a small script that modifies a file after checkout based on the value of $(git branch). You don't mention exactly what would need to happen, but it would likely involve sed.

    You might add the relevant file to a .gitignore file, or maybe write a pre-commit hook, so that your change doesn't accidentally propagate to the public repo.

提交回复
热议问题