<?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>Forem: Zacharias Georgopoulos</title>
    <description>The latest articles on Forem by Zacharias Georgopoulos (@zachgeo).</description>
    <link>https://forem.com/zachgeo</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%2F562971%2F6ef1fa8e-6442-4d4a-975c-dc9c6303057e.jpeg</url>
      <title>Forem: Zacharias Georgopoulos</title>
      <link>https://forem.com/zachgeo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/zachgeo"/>
    <language>en</language>
    <item>
      <title>Squash feature branch commits before merging to main</title>
      <dc:creator>Zacharias Georgopoulos</dc:creator>
      <pubDate>Sat, 08 Feb 2025 13:48:21 +0000</pubDate>
      <link>https://forem.com/zachgeo/squash-feature-branch-commits-before-merging-to-main-266l</link>
      <guid>https://forem.com/zachgeo/squash-feature-branch-commits-before-merging-to-main-266l</guid>
      <description>&lt;p&gt;&lt;strong&gt;What I learned today...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;Today, I learned how to &lt;strong&gt;squash my commits from my feature branch before merging to main&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I was working in a feature branch for couple of days and I had made a lot of commits, but I wanted to squash all of my feature branch commits to one commit, to keep my main branch clean.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git rev-list main..feature | wc -l&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git rebase -i HEAD~n&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then replace "pick" with "squash" for all commits except the first one and save the file.&lt;/p&gt;

&lt;p&gt;On the new editor which will come up, delete all the commit messages there, write a new one and save the it. This will be the only commit message of your feature branch.&lt;/p&gt;

&lt;p&gt;Then you can proceed with the merge of the featuer branch to main.&lt;/p&gt;

&lt;p&gt;Please leave a comment if you have a better solution.&lt;/p&gt;

&lt;p&gt;Bye :)&lt;/p&gt;

</description>
      <category>git</category>
      <category>tutorial</category>
      <category>devops</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
