DEV Community

Mirnes Mrkaljevic
Mirnes Mrkaljevic

Posted on • Originally published at optimalcoder.net on

1 1

Make Git Log Great (Again): Merge vs Rebase

A well-maintained Git log is more than just a record of commits—it’s a story of your project’s growth, collaboration, and problem-solving. But as projects scale and teams grow, Git logs can become cluttered, making it harder to trace changes, understand context, or troubleshoot issues.

In this post, we’ll explore strategies to make your Git log more readable, structured, and useful—because a great Git log isn’t just good practice; it’s a competitive advantage.

Simple Merging

Let's kick off with a simple merging strategy, the one we are all probably most familiar with. For simplification purposes, let's assume we have one main branch that represents the current development branch. Every team member creates their own branch when they want to work on a specific feature and continues working on that feature branch until it is finished. Once it's done, they merge their feature branch into the main branch, and all their work is integrated into the main branch. Then, they can move on to the next feature. Below is a small drawing that represents the described behavior.

What Happens When a Feature Branch Takes Longer to Implement?

Here comes the first problem: what if our feature branches are not short and need to be implemented over a longer period of time? In this case, we risk our feature branch becoming outdated compared to the main branch.

We can solve this problem by more frequently merging changes from the main branch into our feature branch. This keeps our branch updated with the latest changes from the main branch and helps avoid the risk of encountering a lot of conflicts when we eventually merge the feature branch back into the main branch. A small illustration of this concept can be found in the image below.

On one hand, we have reduced the likelihood of larger conflicts when merging our feature branch into the main branch. However, on the other hand, we are making our Git log harder to read and introducing tightly coupled commits, which makes reverting changes more challenging—and in real-world scenarios, almost impossible. The problem becomes even worse as the team grows and feature branches take longer to complete.

Another Approach: Simple Rebase

Now, let us take a look at the same example, but this time using rebasing instead of merging. This means that when we need to update the feature branch with the current main branch, we rebase the feature branch onto the current main. Similarly, when we want to update the current main branch with our feature branch, we rebase the main branch onto the rebased feature branch. Below is an image illustrating this example in contrast to the merging approach.

Here, we can see that the Git log becomes much more readable and easier to track when features are integrated into the main branch. In this example, we have displayed just one feature branch and a simplified main branch for illustration purposes, but this approach can also be applied to much more complex scenarios.

Can it be improved?

Yes, we can further improve the example above by simply squashing the feature branch into a single commit before including its changes in the main branch. For illustration purposes, we will display only the last two steps.

With this final step, we’ve streamlined our feature branches into a single commit in the Git log. This approach not only condenses the feature development into a neat, single entry, but also transforms the Git log into a clean, chronological timeline. By simplifying the development history, the log becomes much easier to follow, maintain, and understand—especially when navigating through complex projects. Moreover, with fewer commits to manage, it’s much simpler to identify changes, isolate specific updates, and, if needed, revert them with less risk of unintended consequences. This results in a more organized and manageable Git history, which ultimately benefits both individuals and teams working on the project.

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay