Where to keep the differences between dev and the manufacturing industry in git?

I have a project that I manage from a git repository. We use the progit branching strategy (as described in the accepted answer, here: Git branching strategy for a small development team ), where one branch is a production branch and the other branch is a development / testing branch. We deploy the code using the structure.

When we are ready to release a new version with git, we will merge the development / testing branch into a production branch, and then expand the production branch using fabric. The problem is that there are code differences between development and production - some logo changes, some different DB nodes / credentials, something like that. I save the .patch file containing the differences and use the template to apply the patch when deploying the production environment, but this does not work so well. In particular, it completely fails, if some code around the patch has changed - the patch is not applied, and my deployment is interrupted.

I was wondering if I should just apply all my changes to the production branch directly? What are the disadvantages of this?

One specific use case I'm worried about is if we need to make a fix. Currently, we are doing this based on the production environment, making changes, and then we combine this branch in both development and production. If the production branch is different from development, can these changes be pulled into the development branch when the patch is merged into development?

+6
source share
2 answers

Basically, your question boils down to β€œhow can I make changes to one branch, and then so that this change does not spread when I merged into another?”. It is quite simple. At the moment, I assume that your production branch is just a series of mergers, both from the dev branch and from the patch branch. Therefore, presumably doing git merge production in your development branch does not make any changes. With this in mind, continue and make changes to the manufacturing industry. Now lock them. Now browse through the development branch and run git merge -s ours production . This basically means "merge with production, but reject all their changes." This will create a merge commit, but will not really affect your development branch.

After this merge, you can now merge your production branch into development (or rather merge patch branches) without worrying, because your production commit is now merged into development (despite the fact that the changes themselves were rejected). Thus, combining your patch branches will not lead to production-only code.

Once you do this, the only time you ever need to go back and reapply this trick is if you make more changes just for production. If you make changes to the development branch that contradict your production changes, when you combine development into production, you can go ahead and take the production side of conflicts without any problems.

+9
source

I also have this request in the dev and production branch. I don’t think git merge -s ours ** is a good solution, because it can simply guarantee that later one merge will not be overwritten, and after that it will cause the parent relationship between dev and production. You have to use git merge -s ours ** every time and this will make the graph journal really ugly and pointless.

Therefore, I recommend using

git cherry pick

. This provides the content you want to pull.

0
source

Source: https://habr.com/ru/post/906805/


All Articles