<?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: Dometrain</title>
    <description>The latest articles on DEV Community by Dometrain (@dometrain).</description>
    <link>https://dev.to/dometrain</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3904155%2Fb00c1fdd-0dbb-48da-82d7-16e16a1f6a01.jpeg</url>
      <title>DEV Community: Dometrain</title>
      <link>https://dev.to/dometrain</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dometrain"/>
    <language>en</language>
    <item>
      <title>Your Git Tree Looks Like a Crime Scene: How to Write Commits That Don’t Suck</title>
      <dc:creator>Dometrain</dc:creator>
      <pubDate>Thu, 28 May 2026 13:52:23 +0000</pubDate>
      <link>https://dev.to/dometrain/your-git-tree-looks-like-a-crime-scene-how-to-write-commits-that-dont-suck-47fg</link>
      <guid>https://dev.to/dometrain/your-git-tree-looks-like-a-crime-scene-how-to-write-commits-that-dont-suck-47fg</guid>
      <description>&lt;p&gt;It’s Friday at 4:45 PM. You’re packing your bag, thinking about the weekend, when the team lead drops a message in Slack: “The production billing engine is throwing random database exceptions. Something broke in the last deploy. We need to find out what changed.”&lt;/p&gt;

&lt;p&gt;You jump onto GitHub, open the main branch, and look at the commit history from the last 24 hours to find the culprit. This is what you see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;wip&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fixed bug&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;hope this works&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;typo&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;clean up code&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;actually fixing it now&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fuck regex&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You look at the diffs. The commit labeled &lt;code&gt;clean up code&lt;/code&gt; contains 14 changed files, two database migrations, and a completely rewritten authentication handler. The commit labeled &lt;code&gt;typo&lt;/code&gt; actually changed a critical calculation in the payment pipeline.&lt;/p&gt;

&lt;p&gt;You can't trace anything. You can't safely revert a single commit because they are all massive, tangled balls of unrelated changes wrapped in useless labels. You’re stuck doing a manual line-by-line code review of 400 changes while the system bleeds cash.&lt;/p&gt;

&lt;p&gt;If this is what your Git history looks like, you aren't just writing messy commits. You are actively torturing your teammates, your future self, and your incident response team. It’s time to talk about Git hygiene.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Git is a Chronicle, Not a "Save Game" Button
&lt;/h2&gt;

&lt;p&gt;The root cause of a garbage Git tree is a fundamental misunderstanding of what Git is for.&lt;/p&gt;

&lt;p&gt;Many developers treat Git like the quick-save button in a video game. They write three lines of code, smash &lt;code&gt;git commit -am "wip"&lt;/code&gt;, and repeat this every ten minutes just in case their laptop explodes.&lt;/p&gt;

&lt;p&gt;Let's clarify something: Your local branch belongs to you. The shared history belongs to the team.&lt;/p&gt;

&lt;p&gt;It is completely fine to commit absolute garbage locally while you are figuring out a problem. Knock yourself out. But the moment you open a Pull Request to merge that code into a shared branch (&lt;code&gt;main, dev&lt;/code&gt;, etc.), you have a responsibility to clean your room. The history should read like an organized, step-by-step story of how a feature was built—not a real-time stream of consciousness from a confused developer.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The Anatomy of a Commit That Doesn't Suck
&lt;/h2&gt;

&lt;p&gt;A good commit message is a form of asynchronous communication. It exists to answer two questions for the person reading it three years from now: What changed? and Why did it change?&lt;/p&gt;

&lt;p&gt;To do this effectively, the industry has a widely accepted standard called the 50/72 Rule. It’s incredibly simple, yet almost nobody follows it by default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Plaintext
Summarize the change in 50 characters or less (Imperative mood)

More detailed explanatory text, if necessary. Wrap it to about 72 
characters. Focus on WHY the change was made, not just WHAT changed. 
Reference any relevant issue or ticket numbers at the bottom.

Fixes #402
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Rules of the Subject Line:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use the Imperative Mood: Write your commit subject as if you are giving a command to the codebase. Use &lt;code&gt;Add checkout endpoint&lt;/code&gt;, not &lt;code&gt;Added checkout endpoint&lt;/code&gt; or &lt;code&gt;Adding checkout endpoint&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pro-Tip:&lt;/strong&gt; A good trick to check this is to complete the sentence: "If applied, this commit will... [Your Subject Line]." If it makes grammatical sense, you’re doing it right.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Capitalise the first letter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do not end the subject line with a period. It’s a title, not a sentence.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep it short: Under 50 characters ensures it doesn't get truncated in GitHub or terminal logs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Rules of the Body:
&lt;/h2&gt;

&lt;p&gt;The code tells you how something was done. The commit body should tell you why. If you had to implement a weird workaround because a third-party API has a known bug, put it in the commit body. The person debugging this code in 2029 needs to know you didn't just write that ugly code because you were lazy, you wrote it because you were constrained.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Your Secret Weapon: Interactive Rebasing
&lt;/h2&gt;

&lt;p&gt;"But I like making tiny, messy commits while I work! It helps me track my thoughts!" Great. Keep doing that. But before you hit that "Create Pull Request" button, you need to run an Interactive Rebase to squash your messy drafts into a clean production history.&lt;/p&gt;

&lt;p&gt;Let's say you're on a feature branch and you've made 5 messy commits. Run this in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Bash
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;This opens a text menu in your editor that looks 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;Plaintext
pick a1b2c3d Add initial checkout logic
pick e4f5g6h wip
pick i7j8k9l typo fix
pick m0n1o2p refactor billing service
pick q3r4s5t hope this works
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This menu allows you to rewrite history before anyone else sees it. You can change &lt;code&gt;pick&lt;/code&gt; to commands like &lt;code&gt;squash&lt;/code&gt; (to blend a commit into the one above it) or &lt;code&gt;reword&lt;/code&gt; (to fix a bad message).&lt;/p&gt;

&lt;p&gt;If you update the menu to look 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;Plaintext
pick a1b2c3d Add initial checkout logic
squash e4f5g6h wip
squash i7j8k9l typo fix
pick m0n1o2p Refactor billing service parameters
squash q3r4s5t hope this works
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you save and close, Git will magically compress those 5 messy, chaotic commits into 2 clean, logical steps. Your &lt;code&gt;wip&lt;/code&gt; and &lt;code&gt;typo fix&lt;/code&gt; commits disappear from history, absorbed into the main feature logic where they belong. Your Git tree goes from looking like a crime scene to a masterclass in professional software delivery.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Git is a Forensic Tool, Use It Like One
&lt;/h2&gt;

&lt;p&gt;When you maintain high Git hygiene, the tool starts working for you. You gain access to advanced forensic commands that make debugging complex system bugs incredibly fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  git log --oneline
&lt;/h2&gt;

&lt;p&gt;Instead of scrolling through pages of text, you get a clean, high-level map of the system's evolution. If your messages are disciplined, you can spot anomalous changes in seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  git blame
&lt;/h2&gt;

&lt;p&gt;When you find a broken line of code, &lt;code&gt;git blame&lt;/code&gt; tells you the exact commit that introduced it. If that commit message says &lt;code&gt;Fix database deadlock under high load (#204)&lt;/code&gt;, you instantly have the context, the pull request, and the original business requirements behind that line of code. If it says &lt;code&gt;wip&lt;/code&gt;, you have nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  git bisect
&lt;/h2&gt;

&lt;p&gt;This is the holy grail of debugging. If you know the app worked perfectly on Monday, but it's broken today, and there are 200 commits in between, you don't have to manually check them all. &lt;code&gt;git bisect&lt;/code&gt; uses a binary search algorithm to find the exact commit that broke the app. It checks a commit in the middle, asks you if the code is good or bad, and narrows down the search. If your commits are small and atomic, &lt;code&gt;git bisect&lt;/code&gt; will point to a single 10-line change, and your bug is found in minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Moving Past the Coder Mindset
&lt;/h2&gt;

&lt;p&gt;It’s easy to look at things like commit formatting, interactive rebasing, and branching hygiene as "extra work." Juniors often complain that it slows them down.&lt;/p&gt;

&lt;p&gt;But true seniority isn't about how fast you can type code into a file. It’s about how easily that code can be maintained, debugged, and understood by a team over a multi-year lifecycle. A developer who leaves a trail of unreadable commits behind them is creating a tax that the rest of the team has to pay every time there is a production incident.&lt;/p&gt;

&lt;p&gt;Excellent development hygiene is a habit that has to be learned intentionally. Most bootcamps and standard video platforms will teach you how to run &lt;code&gt;git commit -m "first commit"&lt;/code&gt;, but they completely ignore the operational realities of working on production codebases at scale.&lt;/p&gt;

&lt;p&gt;This is where real-world, no-nonsense engineering training makes a difference. At &lt;a href="https://dometrain.com/" rel="noopener noreferrer"&gt;Dometrain&lt;/a&gt;, our courses focus heavily on the practices that define the top 1% of engineers. We don't just show you how to write modern C# syntax; we focus on the everyday developer habits—from clean testing to robust architectural patterns—that help you step off the mid-level plateau and confidently own a production ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Git Hygiene Checklist
&lt;/h2&gt;

&lt;p&gt;Before you push your next branch to the remote repository, spend two minutes running through this checklist:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Run &lt;code&gt;git log&lt;/code&gt; locally: Look at your branch history. Does it look like a cohesive story or a messy scratchpad?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interactive Rebase: If you see &lt;code&gt;wip&lt;/code&gt;, &lt;code&gt;typo&lt;/code&gt;, or duplicate commits, run &lt;code&gt;git rebase -i&lt;/code&gt; and squash them down.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check your subject lines: Are they under 50 characters? Do they start with a capital letter? Are they written in the imperative mood (&lt;code&gt;Add&lt;/code&gt;, &lt;code&gt;Fix&lt;/code&gt;, &lt;code&gt;Remove&lt;/code&gt;)?&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Isolate your changes: Ensure a single commit does one thing. Don't mix formatting changes, feature development, and dependency updates into a single giant commit.&lt;/p&gt;

&lt;p&gt;Your Git tree is a direct reflection of your engineering discipline. Stop treating it like an automated backup tool, clean up your history, and start writing commits that make your teammates want to buy you a coffee instead of tracking you down after a failed deployment.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
