<?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 Will Ediger on Medium]]></title>
        <description><![CDATA[Stories by Will Ediger on Medium]]></description>
        <link>https://medium.com/@willediger?source=rss-4e5307339f4a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Will Ediger on Medium</title>
            <link>https://medium.com/@willediger?source=rss-4e5307339f4a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:46:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@willediger/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[Deleting midstream Git commits]]></title>
            <link>https://medium.com/@willediger/deleting-midstream-git-commits-75944272d6c8?source=rss-4e5307339f4a------2</link>
            <guid isPermaLink="false">https://medium.com/p/75944272d6c8</guid>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Will Ediger]]></dc:creator>
            <pubDate>Wed, 16 Jan 2019 09:12:43 GMT</pubDate>
            <atom:updated>2019-01-16T09:15:38.168Z</atom:updated>
            <content:encoded><![CDATA[<p>So here’s something I just learned/taught myself in git: deleting commits from the middle of the stream.</p><p>Scenario: I “finished” a project, so I did a commit of “mvp complete” (which, in my case, the “mvp complete” commit was just the addition of a comment saying “mvp complete”). However, I realized that I didn’t do one of the challenges exactly correctly. So, what to do? I had already multiple commits after that for the stretch goals. Well, I chose to rewrite history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XD-7BGLDA1NYRzet1CvgCw.png" /><figcaption>Doctor Strange (2016) rewrites the history of an apple</figcaption></figure><p>Since we’re rewriting history, this can be a bit dangerous. You likely wouldn’t want to do this on a shared repository without a lot of communication with your team, and understanding of what you’re doing. However, I’m working on a personal repository, so the main thing I need to worry about is to not make an unrecoverable mistake. I made sure that I didn’t accidentally wipe out all of my work. To do that, I made a new branch to save a snapshot of the branch I wanted to work on: git branch &lt;new branch&gt;</p><p>One way to handle an errant commit would be to do: git revert &lt;SHA-1 of commit to delete&gt;, which would create a <em>new</em> commit at the end of the stream which undid everything the “mvp complete” commit did. However, this wasn’t exactly what I wanted, since it would leave the “mvp complete” commit alone and just add another commit at the end, undoing it. I wanted to remove the “mvp complete” commit completely. To do that, I would need to use git rebase. Specifically: git rebase -i &lt;SHA-1 of commit to delete&gt;^ <strong>Note the </strong><strong>^ after the commit SHA-1.</strong></p><p>This brings up a text file of the commits in chronological order, with the commit you want to delete at the top, continuing with subsequent commits below it. To delete that commit, you delete its line, save the file, and close the text file. This tells git rebase to delete that commit. At this point, the commit is deleted on your local repository. To push those changes back to the remote repository on GitHub, you run git push origin &lt;branch name&gt; -f, which forces your local repository version up to the remote repo. This results in the deleted commit being removed from GitHub.</p><p>Then, you verify that the GitHub history looks like you expect it to. If everything looks good, then you can delete the branch you created on your local repo: git branch -D &lt;new branch&gt;. If something got messed up with your GitHub history somehow, you can push your &lt;new branch&gt; to GitHub: git push origin &lt;new branch&gt;, and then on GitHub, you can delete the old branch, and rename the &lt;new branch&gt; to the same name as the old branch, and everything should be right in the world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75944272d6c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>