<?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 Joshua on Medium]]></title>
        <description><![CDATA[Stories by Joshua on Medium]]></description>
        <link>https://medium.com/@konekoya_84442?source=rss-1a2f1a099f62------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FXjDyiIDM8C0ypjJHCNfNw.jpeg</url>
            <title>Stories by Joshua on Medium</title>
            <link>https://medium.com/@konekoya_84442?source=rss-1a2f1a099f62------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 19:43:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@konekoya_84442/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[Delete your Git history]]></title>
            <link>https://medium.com/@konekoya_84442/delete-your-git-history-717f4c18ba30?source=rss-1a2f1a099f62------2</link>
            <guid isPermaLink="false">https://medium.com/p/717f4c18ba30</guid>
            <category><![CDATA[git-history]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[git-init]]></category>
            <category><![CDATA[git-reset]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Joshua]]></dc:creator>
            <pubDate>Mon, 21 Nov 2022 02:13:08 GMT</pubDate>
            <atom:updated>2022-11-21T02:25:25.532Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*poVqhn3nbvTSeNlajRO8yw.jpeg" /><figcaption>Story image</figcaption></figure><p>The other day I was trying to switch a GitHub repo from private to public. And since the repo contains some sensitive data, I somehow need to erase all the Git commit history so the sensitive data isn’t included in the commit history. And you can do so by following these steps:</p><ol><li><strong>Delete the </strong><strong>.git directory in your local repo</strong></li></ol><pre>$ rm -rf .git</pre><p>This way, the commit history is erased entirely. <strong>Just note that this is a destructive command,</strong> make sure you know what you’re doing before typing the command :)</p><p><strong>2. Re-initialize the repo with Git</strong></p><pre>$ git init</pre><p>After successfully initializing the repo, you will also need to create your first commit and just include the <em>files (remove the sensitive data in this step, if you have any) </em>you wanted:</p><pre>git add . # Here, I want to add everything that&#39;s unstaged locally</pre><p>And create the first commit:</p><pre>git commit -m &quot;Initial commit&quot;</pre><p><strong>3. Optional: Rename the branch name from main to master</strong></p><pre>git branch -M master</pre><p>This is an optional step. I don’t know about you, but I really don’t like using <em>main</em> as the default branch name instead of <em>master.</em> I like the idea behind it, but many repos that I own are already using <em>master </em>as the “main” branch, and switching them all to main is such a big task.</p><p><strong>4. Add remote info and force push</strong></p><pre># Replace the part ${...} with your own GitHub repo<br><br>$ git remote add origin ${YOUR_REMOTE_GIT_REPO} </pre><p>First, you need to add the remote repo address and then:</p><pre>$ git push --set-upstream origin master -f</pre><p>Here is another destructive command, and this command will rewrite your <em>remote</em> repo history, so ensure you know what you’re doing.</p><p>And you should now have a new Git repo which only contains one single commit in the Git history :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=717f4c18ba30" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>