<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Juljan M</title>
    <description>The latest articles on DEV Community by Juljan M (@juljan_m_534e1f4d355f0bc2).</description>
    <link>https://dev.to/juljan_m_534e1f4d355f0bc2</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2020913%2F17dcde68-67cf-49e5-b5d9-3ab67ac9721d.png</url>
      <title>DEV Community: Juljan M</title>
      <link>https://dev.to/juljan_m_534e1f4d355f0bc2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/juljan_m_534e1f4d355f0bc2"/>
    <language>en</language>
    <item>
      <title>Clean Git History Is a Professional Courtesy: Interactive Rebase wins</title>
      <dc:creator>Juljan M</dc:creator>
      <pubDate>Tue, 03 Nov 2026 18:24:07 +0000</pubDate>
      <link>https://dev.to/juljan_m_534e1f4d355f0bc2/clean-git-history-is-a-professional-courtesy-interactive-rebase-wins-162l</link>
      <guid>https://dev.to/juljan_m_534e1f4d355f0bc2/clean-git-history-is-a-professional-courtesy-interactive-rebase-wins-162l</guid>
      <description>&lt;p&gt;&lt;em&gt;Until your branch is merged, your history is yours. After that, it belongs to the team (and company too).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As developers, we spend much more time reading code than writing it. Yet we often neglect the readability of our Git history.&lt;/p&gt;

&lt;p&gt;I’ve been writing software over the last 15 years, I’ve worked with many teams, countries, repositories, and review cultures. And I’ve met only one company where cleaning up Git history with interactive rebase was not just tolerated, but welcomed and actively supported.&lt;/p&gt;

&lt;p&gt;That experience shaped my view. A clean Git log is not vanity. It’s a professional courtesy to everyone who will handle the code after you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Local history is for you. Shared history is for the team.
&lt;/h2&gt;

&lt;p&gt;While a feature branch is open and unmerged, it is your private sandbox. You should commit often. Experiment. Break things. Save your progress with messages like wip, fix, try again, forgot file.&lt;/p&gt;

&lt;p&gt;That’s completely fine.&lt;/p&gt;

&lt;p&gt;But before you open a Pull Request, you have a responsibility to clean up your mess. And before you merge code, you have to check count of commits.&lt;/p&gt;

&lt;p&gt;This is where &lt;code&gt;git rebase -i&lt;/code&gt; — interactive rebase — shines.&lt;/p&gt;

&lt;p&gt;The rule is simple:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rebase before merge. Never rewrite shared history after merge.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Once your branch lands in main, it becomes part of the team’s history and company value asset. But until then, you can — and often should — shape it into something readable. Transform your mess into the value before closing the branch. You are paid not for being messy.&lt;/p&gt;

&lt;p&gt;Good naming at every stage of history, clear variable names, meaningful commits, and a clean history are always indicators of a healthy developer. They show that the developer is a mindful person — not someone in a hurry.&lt;/p&gt;

&lt;p&gt;Every small piece of it reflects a company’s culture — the way the business actually works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I rebase before merging
&lt;/h2&gt;

&lt;p&gt;A feature branch should ideally contain a small number of atomic, meaningful commits. Not twenty-five fragments of your debugging session and "code style fix" after that.&lt;/p&gt;

&lt;p&gt;Interactive rebase lets you:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Squash noisy commits into one logical change.
Reword vague messages into clear explanations.
Drop accidental commits, secrets, or debug code.
Reorder commits so the story makes sense.
Edit commits that were almost right.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This matters for several reasons.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Code reviews become easier
&lt;/h3&gt;

&lt;p&gt;A reviewer should not have to mentally diff ten commits named fix, fix again, and please work. They should see a clean sequence of intentional changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. &lt;code&gt;git bisect&lt;/code&gt; remains useful
&lt;/h3&gt;

&lt;p&gt;If every commit in your history is supposed to build and work, git bisect can find the exact commit that introduced a bug. WIP commits break that assumption.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Reverting is simpler
&lt;/h3&gt;

&lt;p&gt;It’s much easier to revert one well-defined feature commit than to untangle fifteen messy ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The repository tells a story
&lt;/h3&gt;

&lt;p&gt;A clean history explains why a change was made, not just what was typed. That story is valuable months or years later.&lt;/p&gt;

&lt;h2&gt;
  
  
  A simple interactive rebase workflow
&lt;/h2&gt;

&lt;p&gt;Let’s say you have five commits on your branch and you want to clean them up before opening a PR.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase &lt;span class="nt"&gt;-i&lt;/span&gt; HEAD~5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, if you want to rebase onto the latest main:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git fetch origin
git rebase &lt;span class="nt"&gt;-i&lt;/span&gt; origin/main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your editor will open with something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pick 1a2b3c4 Add login form
pick 5d6e7f8 fix validation
pick 9a0b1c2 forgot to remove console.log
pick 3d4e5f6 Add tests for login
pick 7g8h9i0 fix typo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can rewrite it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pick 1a2b3c4 Add login form
squash 5d6e7f8 fix validation
squash 9a0b1c2 forgot to remove console.log
reword 3d4e5f6 Add tests for login
drop 7g8h9i0 fix typo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save, close, and Git will guide you through the rest.&lt;/p&gt;

&lt;p&gt;If you’ve already pushed the branch, you’ll need to force-push. Use the safer option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--force-with-lease&lt;/code&gt; checks that no one else has pushed to the branch since your last fetch. It’s not magic, but it’s much safer than --force.&lt;/p&gt;

&lt;p&gt;And again: never rebase main, develop, or any branch that other people are building on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common objections
&lt;/h2&gt;

&lt;p&gt;“But I want to keep the honest history.”&lt;/p&gt;

&lt;p&gt;Keep the honest history in your local branch. The shared history should be useful. Honesty is not the same as noise.&lt;/p&gt;

&lt;p&gt;“What if I break something?”&lt;/p&gt;

&lt;p&gt;Rebase is not destructive if you use it carefully. Git keeps reflog. You can recover. But yes, coordinate with your team if the branch is shared.&lt;/p&gt;

&lt;p&gt;“Isn’t this just extra work?”&lt;/p&gt;

&lt;p&gt;It takes two minutes before a PR. It saves hours for reviewers, debuggers, and future maintainers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The culture matters
&lt;/h2&gt;

&lt;p&gt;Tools are only half the story. A team has to support this practice.&lt;br&gt;
The company where interactive rebase is welcomed and supported cultivates a good engineering culture. Reviewers expected a clean history. Developers helped each other learn how to achieve it.&lt;/p&gt;

&lt;p&gt;That creates a difference. The Git log became readable. Reviewing is faster. Debugging easier. The repository looks professional.&lt;/p&gt;

&lt;p&gt;As a manager i'm able to put together a report for the business just by reading the clean Git story of each developer.&lt;/p&gt;

&lt;p&gt;I wish more companies treated it that way.&lt;/p&gt;

</description>
      <category>codequality</category>
      <category>git</category>
      <category>softwareengineering</category>
    </item>
  </channel>
</rss>
