Resolving conflicts when merging release to develop
Quick post on something I recently had to deal with related to Gitflow. I hope you will find it helpful if you ever find yourself in a similar situation.
Problem
I had a release
branch cut from develop
and over a couple of days the two branches diverged from each other. After releasing to Production, it was time to resolve conflicts and back-merge release
branch into develop
.
The challenges were:
- Need to resolve a conflict without changing any code in the
release
branch (see below for reasoning) - Need to go through a pull request in order to merge into
develop
— direct commits todevelop
are not supported in my repo
There are several reasons not to update
release
branch after deploying to Production
- As part of the Gitflow workflow, the
release
branch also gets tagged and merged tomaster
which will represent a snapshot of what was released to Production. - In my CI/CD setup, pushing any changes to
release
branch triggers a new release candidate build to Play Store.
Solution
The solution turned out to be pretty simple — by using an intermediary branch to resolve a conflict in.
Step 1. Create a new branch based on release
. Let’s call it resolve-conflict
Step 2. Merge develop
into resolve-conflict
as a merge commit
git merge develop
Step 3. Resolve conflicts in resolve-conflict
branch— now you should be able to merge this branch into develop
.
Step 4. Merge resolve-conflict
into develop
And that’s it! The open pull request release
-> develop
will now automatically be closed since the version control system (Github, Bitbucket, Gitlab, etc.) will recognize that the code in release
has now been integrated into develop
.
Visit my Android blog to read about Jetpack Compose and other Android topics