<?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"><channel><title><![CDATA[Ademola]]></title><description><![CDATA[Ademola]]></description><link>https://ademola101.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 09:10:51 GMT</lastBuildDate><atom:link href="https://ademola101.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to Gitignore (untrack) files already pushed to GitHub repository.]]></title><description><![CDATA[Most developers usually initialize the folder they are working from as their Github repository. However, some files or directories may be present in that folder that you would not want to push to GitHub (database file, environment variables etc).
Add...]]></description><link>https://ademola101.hashnode.dev/how-to-gitignore-untrack-files-already-pushed-to-github-repository</link><guid isPermaLink="true">https://ademola101.hashnode.dev/how-to-gitignore-untrack-files-already-pushed-to-github-repository</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Ademola Ogunmokun]]></dc:creator><pubDate>Fri, 22 Jan 2021 19:39:48 GMT</pubDate><content:encoded><![CDATA[<p>Most developers usually initialize the folder they are working from as their Github repository. However, some files or directories may be present in that folder that you would not want to push to GitHub (database file, environment variables etc).
Adding the file(s) or directories to <a target="_blank" href="https://git-scm.com/docs/gitignore">gitignore</a> seems to solve the issue. 
However, sometimes, you might have unknowingly push that file(s) to our GitHub repository failing or forgetting to gitignore the file(s) we did not want to push. </p>
<p>Once the file has been pushed, adding it to gitignore afterwards would not untrack the file from that commit. The file would still be present in the repository.</p>
<p>If you are having that kind of issue, follow these simple 5 steps to solve the problem.</p>
<h2 id="step-1">Step 1:</h2>
<p><strong>Git commit</strong></p>
<p>Make sure the changes you have made on the projects have been added and committed, including the .gitignore file.</p>
<p>Do this by:</p>
<pre><code class="lang-git">git add .
git commit -m "initial commit"
</code></pre>
<h2 id="step-2">Step 2:</h2>
<p><strong>Remove all the files in the repository</strong>.</p>
<p>You do that by:</p>
<pre><code class="lang-git">git rm -r --cached .
</code></pre>
<p>rm is the remove command which removes all the files in the repo,  adding <strong>-cached</strong> allow us to remove the files from the index. Our files are still present.</p>
<h2 id="step-3">Step 3:</h2>
<p><strong>Add everything</strong></p>
<p>The next step is to re-add/track our files. By doing this, the files in the . gitignore file will not be tracked.</p>
<p>This is done by:</p>
<pre><code class="lang-git">git add .
</code></pre>
<h2 id="step-4">Step 4:</h2>
<p><strong>Commit the changes.</strong></p>
<p>Thus, let's commit our changes by </p>
<pre><code class="lang-git">git commit -m "gitignore fix"
</code></pre>
<h2 id="step-5">Step 5:</h2>
<p><strong>Push to GitHub</strong></p>
<p>After we are through with everything, we still need to push it to our online GitHub repository by </p>
<pre><code class="lang-git">git push
</code></pre>
<p>Thanks for reading. </p>
]]></content:encoded></item></channel></rss>