Git conflicts between two protected branches

88 Views Asked by At

So I have three branches in total deploy release and main

Each of this represents a environment to be deployed on

Branches:     deploy --> release --> main 
Environments: dev        uat         PROD

Now the dev branch is a non-protected branch, means you can push and do all sort of stuff on it

But my release and main branches are protected branches which only accepts merges from other branch

Whenver I have problems when merging from dev to release I can directly commit the changes to the dev branch Problem is that whenever I do release to main I get conflicts which I can't directly commit to release

Could anyone suggest how I work with this

If it helps, this is on GitLab

Thanks in advance

I searched online that you should create another branch through release, and then merge main into release and fix the conflicts

But the moment I go to merge this new branch to release it doesn't show me any changes (Reason being that always the lower branches would have the updated code)

And after that I would assume that my Merge Request would be deployed but that is still blocked

1

There are 1 best solutions below

0
LeGEC On

Create an unprotected work branch, and solve your merge conflicts in that branch.

Here is an illustration for the "merge main into release" action:

  1. create a work branch from release:
git checkout -b merge-main-into-release release
  1. merge main into that branch:
git merge main

fix the conflicts in that work branch

  1. push that work branch to your remote
git push origin merge-main-into-release
  1. open a merge request to merge this branch into release

that merge request should be ok -- i.e: no conflicts there.