October 6, 2022

Robotic Notes

All technology News

How to Flatten git Commits

2 min read

One of my least favorite tasks as a software engineer is resolving merge conflicts. A simple rebase is a frequent occurrence but the rare massive conflict is inevitable when many engineers work in a single codebase. One thing that helps me deal with large rebases with many merge conflicts is flattening a branch’s commits before fixing merge conflicts. Let’s have a look at how to flatten those commits before resolving those conflicts!

My typical command for rebasing off of the main branch is:

# While on the feature branch...
git rebase -i master

To flatten commits before the rebase, which can make resolving merge conflicts easier, you can slightly modify the original command:

# While on the feature branch...
# git rebase -i HEAD~[NUMBER_OF_COMMITS]
git rebase -i HEAD~10

The example above would flatten the last 10 commits on the branch. With just one single commit, you avoid the stop-start nature of fixing merge conflicts with multiple commits!

Website performance monitoring
Website performance monitoring
Website performance monitoring
Website performance monitoring
  • CSS @supports

    CSS @supports

    Feature detection via JavaScript is a client side best practice and for all the right reasons, but unfortunately that the same functionality has not been available within CSS. What we end up doing is repeating the same properties multiple times with each browser prefix. Yuck. Another thing we …

  • JavaScript Promise API

    JavaScript Promise API

    While synchronous code is easier to follow and debug, async is generally better for performance and flexibility. Why “hold up the show” when you can trigger numerous requests at once and then handle them when each is ready? Promises are becoming a big part of the JavaScript world …

  • Multi-Select Transfers Using MooTools 1.2
  • Build a Slick and Simple MooTools Accordion

    Build a Slick and Simple MooTools Accordion

    Last week I covered a smooth, subtle MooTools effect called Kwicks. Another great MooTools creation is the Accordion, which acts like … wait for it … an accordion! Now I’ve never been a huge Weird Al fan so this is as close to playing an accordion as …



Source link