For example, consider I have these Git branches:
- master
- development
- feature
- staging
- production
There isn't any functionality difference between development, staging, and production, except configuration, such as base API URL, client secret key, and the likes.
Whenever there's a change pushed in development, it's eventually merged into staging, which eventually also merged into production. But the configuration differences are preserved between merge.
The problem right now, we're suddenly can't use the development server for a while. So we have to work on staging. But the problem is our work is in feature branch and the feature branch is branching off from the development branch.
In order for the code to be tested, then we must push the changes to feature branch, pull request into development branch, and merged the changes into staging branch, and test it there. But we don't want to commit/push/pull/merge something into staging when it's not tested yet in dev/feature. But if it's not merged into staging then we can't test. We also don't want to manually make changes into the app's "configuration" like base URL and such, as this change is only for a while, until the development server works again. The "configuration" is also spread in several files and it's not that easy as copy and paste.
How can I for a moment let the feature branch use the "configuration" from the staging branch? So I'm thinking like maybe applying the "difference" between staging and development branch onto the feature branch? And then when we can work on development server again, we can reapply the "reverse-difference"? I'm not even sure whether this is possible or not, or if there's a better approach for this, as I'm not well versed in git.
CodePudding user response:
The idea is that "do something unusal for a moment" can easily be solved with Git by "make another branch and play around there". For example:
You build another branch on top of feature
and merge staging
into it:
git checkout -b tmp-feature-for-staging feature
git merge staging
That may produce merge conflicts around the configuration values that differ between development
and staging
. Resolve them in favor of the staging
versions and commit the result.
Then you deploy tmp-feature-for-staging
to the staging server. When the result looks good, you throw away tmp-feature-for-staging
. If you see problems, and you have to modify feature
, do so, then repeat this procedure on the updated feature
breanch.