I have a common git workflow, where you have two main branches: develop
(for development) and master
(for production). All other branches are created from these two and then merged back.
Normally, when there is a bug on production, I create a branch bugfix-*version*
from the master
, and than I merge it back into master. But I need to merge it also to develop
branch to apply this "patch" to all future development as well.
But there are some differences in the code on production and development branches, mainly related to different environments (DB credentials, some variables, paths, etc).
- Now to the problem :
When I merge bugfix
branch (that was created from master) into develop
it doesn't take only the diffs that were presented in that branch, but also all that specific branch-related and environment-related information that is different between the branches.
I could use cherry-pick
to pick only diffs for each commit, but it would mean to copy every single commit from one branch to another. It's messy and doesn't preserve the clean history of changes.
I could use a post-merge script
or somewhat to automatically change the differences between the environments, but it seems too difficult and bug-prone.
Or I could probably merge without committing
, then manually correct all values, and afterwards commit... It seems to be such a common task, that I'm sure there must be a way, some sort of merge strategy, or I don't know what, to solve this problem with the power of git without any workarounds! Or maybe I misunderstood some conceptions and I shouldn't really try to merge these branches?
Thank you in advance!
Example
DEV branch | PROD branch
|
Differences between branches
1. $environment_path = "/www/dev"; | 1. $environment_path = "/www/prod";
2. $db_name = "some_name"; | 2. $db_name = "other_name";
... | ...
The modified lines (new commits)
200-205. "some old lines with a bug" | 200-205. "bugfix"
...
So what do I need is to be able to merge modifications from one branch to another without touching those first lines. "the rest of the script"