Reputation: 87
I have a Git repository in Gerrit, with two branches: master, and production. The production branch is to differ from master by one single commit, which rewrites a config file. It's possible that the branches will differ more greatly in the future, but it will always be in the form of very few commits that make very isolated changes.
I got the production branch set up in Gerrit, and I can submit patches to it and all that. The issues I am having arise from keeping production up to date with master. I tried using git merge --squash, but even still, I get tons of merge conflicts.
What is the proper formula for doing this? I'd like to avoid submitting every patch to Gerrit twice. Do I need to commit around Gerrit's back to get what I want?
Upvotes: 0
Views: 199
Reputation: 1040
As per understanding towards your question, you wanted to merge the desired changes (already submitted to production branch) to master in order to keep your master up-to-date.
Have you tried cherry-picking the patches from production branch to master branch. If not, please try it once. Hope it should work.
Lets suppose you have few patches submitted in production branch. Try using below command to cherry-pick these patches to master.
git cherry-pick commit1..commit2
if getting more merge conflicts, you can also cherry-pick one by one.
git cherry-pick commit1
Try it!!
Upvotes: 0
Reputation: 1148
I would strongly reconsider having a production branch at all. It will only lead to heartache and ongoing maintenance issues.
Instead you should have production and development versions of the config file all in the master branch. Your code will choose which one to use at runtime based on environment variables.
This way you can build one artifact, test it in your development environment, once you're satisfied you will release the exact same artifact to the production environment.
Upvotes: 2