ItsJay
ItsJay

Reputation: 198

merging two git branch but exclude specific lines in a merged file

i have two branches for my project one is for my Local Project and the other is for Depolying to heroku is there is way to use git merge so that i'll be able to merge my local branch into Heroku branch but certain lines of a few merged files do not changes . for example i have a line connecting a socket to my localhost i dont want this line to change relevent line that connect socket to my heroku address or the same applys to port and minor changes like that .

thanks.

Upvotes: 1

Views: 482

Answers (1)

Schwern
Schwern

Reputation: 164679

You'd have to perform the merge and then make another commit to remove the lines. This is a maintenance hassle and its very easy to get cross-contamination.

Instead, best practice is to have a single branch for all deploys. Configuration is done via environment variables (which can have defaults). Then set your values on Heroku using Config Vars. This follows the The Twelve-Factor App for delivering software to 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.

https://12factor.net/config

Upvotes: 2

Related Questions