合并两个 git 分支但排除合并文件中的特定行
merging two git branch but exclude specific lines in a merged file
我的项目有两个分支,一个是我的本地项目,另一个是 Depolying 到 heroku 有没有办法使用 git merge 这样我就可以合并我的本地分支进入 Heroku 分支,但一些合并文件的某些行没有改变。例如,我有一条线将套接字连接到我的本地主机,我不希望这条线改变将套接字连接到我的 heroku 地址的相关线,或者同样适用于端口和类似的微小变化。
谢谢。
您必须执行合并,然后再进行一次提交以删除这些行。这是一个维护麻烦,而且很容易交叉污染。
相反,最佳做法是为所有部署设置一个分支。配置是通过环境变量(可以有默认值)完成的。然后使用 Config Vars. This follows the The Twelve-Factor App 在 Heroku 上设置您的值,以便将软件交付给 Heroku。
Apps sometimes store config as constants in the code. This is a violation of twelve-factor, which requires strict separation of config from code. Config varies substantially across deploys, code does not.
The twelve-factor app stores config in environment variables (often shortened to env vars or env). Env vars are easy to change between deploys without changing any code; unlike config files, there is little chance of them being checked into the code repo accidentally; and unlike custom config files, or other config mechanisms such as Java System Properties, they are a language- and OS-agnostic standard.
我的项目有两个分支,一个是我的本地项目,另一个是 Depolying 到 heroku 有没有办法使用 git merge 这样我就可以合并我的本地分支进入 Heroku 分支,但一些合并文件的某些行没有改变。例如,我有一条线将套接字连接到我的本地主机,我不希望这条线改变将套接字连接到我的 heroku 地址的相关线,或者同样适用于端口和类似的微小变化。
谢谢。
您必须执行合并,然后再进行一次提交以删除这些行。这是一个维护麻烦,而且很容易交叉污染。
相反,最佳做法是为所有部署设置一个分支。配置是通过环境变量(可以有默认值)完成的。然后使用 Config Vars. This follows the The Twelve-Factor App 在 Heroku 上设置您的值,以便将软件交付给 Heroku。
Apps sometimes store config as constants in the code. This is a violation of twelve-factor, which requires strict separation of config from code. Config varies substantially across deploys, code does not.
The twelve-factor app stores config in environment variables (often shortened to env vars or env). Env vars are easy to change between deploys without changing any code; unlike config files, there is little chance of them being checked into the code repo accidentally; and unlike custom config files, or other config mechanisms such as Java System Properties, they are a language- and OS-agnostic standard.