<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Comrade ☭ Hound on Medium]]></title>
        <description><![CDATA[Stories by Comrade ☭ Hound on Medium]]></description>
        <link>https://medium.com/@skylos?source=rss-ec8103b78371------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xzggNseYIL31uDWE.jpeg</url>
            <title>Stories by Comrade ☭ Hound on Medium</title>
            <link>https://medium.com/@skylos?source=rss-ec8103b78371------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 23:03:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@skylos/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Don’t git rebase and squash — branch, reset, and commit!]]></title>
            <link>https://skylos.medium.com/dont-git-rebase-and-squash-branch-reset-and-commit-5a56620a0f06?source=rss-ec8103b78371------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a56620a0f06</guid>
            <category><![CDATA[git-squash]]></category>
            <category><![CDATA[git-rebase]]></category>
            <category><![CDATA[rebase]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[squash]]></category>
            <dc:creator><![CDATA[Comrade ☭ Hound]]></dc:creator>
            <pubDate>Mon, 26 Oct 2020 12:40:04 GMT</pubDate>
            <atom:updated>2020-10-26T12:40:04.275Z</atom:updated>
            <content:encoded><![CDATA[<h3>Don’t git rebase and squash — branch, reset, and commit!</h3><p>Not uncommonly a developer finds themselves in the situation where the mainline has been updated, and they need to merge their changes back. It’s also a reasonable workflow to require that you squash the many commits that were created as work on the branch down into a single commit.</p><p>The canonical answer to this situation is ‘rebase and squash’. You would not be the first to attempt to rebase the mainline into your branch and find the same conflicts asked about again and again. This is highly dangerous — you could easily make a mistake in the repeated questions, misremember the prior conflict resolution, or misunderstand a conflict.</p><p>Now there IS a feature called git rerere — think rebase resolve remember . This is a little known feature that at least will at least not re-ask you every time for the same conflict at each commit being integrated during the rebase. By all means, use it if you MUST rebase. But it too is far too dangerous and fiddly for the goal of a single commit merge.</p><p>Especially when it is entirely possible to bring the branch up to date and squash it without that pain!</p><p>What we’re going to do is make sure we have all the commits from the mainline simply merged into our branch, then reset the HEAD to the mainline state. This reset means that to git it will look like it has the files of the mainline — and you’ve done all your changes of your branch, but they are un-staged. The new changes now shown will be your entire squashed changeset. Sure, this will not include all the commit messages you made in your working branch, but that’s okay — you intended to squash them out anyway!</p><p>So here’s how you do that, starting with definitions:</p><p>&lt;workingBranch&gt; = what you’ve been working on</p><p>&lt;remote&gt; = usually ‘origin’ but I’m not gonna second guess your remote names, friend</p><p>&lt;mainline&gt; = usually ‘master’ but you might not swing that way ;) Github, in particular, uses ‘main’ as the mainline branch for new repositories.</p><p>&lt;pushremote&gt; = Github’s workflow has you push to your own fork, then create a pull request. If you’re not using this model, this is the same as &lt;remote&gt;.</p><p>&lt;squashingBranch&gt; = new branch name separate from your working branch to create your squashed merge request with. If you don’t need to keep the history of your working branch, this can be the same as &lt;workingBranch&gt;.</p><p>&lt;any new files&gt; = files you added in your branch</p><p>&lt;any removed files&gt; = files you removed in your branch</p><pre>git checkout &lt;workingBranch&gt;<br>git fetch &lt;remote&gt;<br>git checkout -b &lt;squashingBranch&gt;<br>git merge &lt;remote&gt;/&lt;mainline&gt; # &lt;if conflicts, resolve and commit!&gt;<br>git reset &lt;remote&gt;/&lt;mainline&gt;<br>git add &lt;any new files&gt;<br>git rm &lt;any removed files&gt;<br>git commit -m “&lt;your commit message&gt;”<br>git push &lt;pushremote&gt; &lt;squashingBranch&gt;</pre><p>Voila! That’s all there is to it. A single cycle of merge conflict resolution, and all those confusing nasty rebase questions are gone.</p><p>And you’ve saved enough time against rebasing with something so basic there’s probably even time to get a pumpkin spice latte. Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a56620a0f06" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>