DEV Community

Cover image for Conciliation Branch in Git
Kevin J. Estevez
Kevin J. Estevez

Posted on β€’ Edited on

3 1

Conciliation Branch in Git

Have you ever fall in the situation where the commit chain from the main branch (prod) differs from the staging branch, either cause by:

  • A cherry-picked commit to main cherry-pick case
  • A bunch of commits squashed and added as a single commit to the main branch squashed commits case

Well it has happened to me a couple times in different teams, and on each case several approaches had bumped up from my colleagues:

  • Address the conflicts manually? πŸ˜₯
  • Revert (hard reset main) the conflicting commits? 😰
  • Hard push (force) the staging branch to main? πŸ˜–

To be honest I'm not a fan of forcing things, I like my Pull Requests to merge soothly into main 😌

so I'll give you the solution to this problem, which I've called Conciliation Branch even though I'm not sure if the term already exist or not, but it's an approach I've made several times to solve this. (as a git lover)

Well let's jump in!

Commands:

Note: all steps we're doing through terminal

$: git fetch
$: git checkout staging

# in case we're not up-to-date with upstream
$: git merge origin/staging

# Create a conciliation branch from staging-branch
$: git checkout -b <conciliation-branch-name>

# merge master back into staging taking "ours" preference
$: git pull -s ours origin master

# push new branch
$: git push <conciliation-branch-name>
Enter fullscreen mode Exit fullscreen mode

And that's it!

Now all you need to do is create a Pull request from your new conciliation-branch to staging-branch

That will allow you then after merged to now open a new Pull Request from staging-branch to master smoothly πŸš€ πŸ₯³

Thanks for reading!, Hope this could help you a lot.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

πŸ‘‹ Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay