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)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay