<?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 Sanika Patange on Medium]]></title>
        <description><![CDATA[Stories by Sanika Patange on Medium]]></description>
        <link>https://medium.com/@sanikapatange?source=rss-1e0c65f2a5ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ap0TboyaDQWooILp-Qc64Q.jpeg</url>
            <title>Stories by Sanika Patange on Medium</title>
            <link>https://medium.com/@sanikapatange?source=rss-1e0c65f2a5ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:34:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sanikapatange/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[Bitbucket — Reduce large repository size on Local and Remote]]></title>
            <link>https://medium.com/@sanikapatange/bitbucket-reduce-large-repository-size-on-local-and-remote-46787ba68011?source=rss-1e0c65f2a5ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/46787ba68011</guid>
            <category><![CDATA[repositories]]></category>
            <category><![CDATA[jira]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[bitbucket]]></category>
            <category><![CDATA[atlassian]]></category>
            <dc:creator><![CDATA[Sanika Patange]]></dc:creator>
            <pubDate>Sat, 02 Apr 2022 23:32:47 GMT</pubDate>
            <atom:updated>2022-04-02T23:33:14.524Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bitbucket — Reduce large repository size on Local and Remote</h3><p>I was working on a project for my company and was about to commit and push all my code to the remote repository on Bitbucket. Many of my local tests performed after the code changes involved the creation of several image files on the local repository. In order to avoid these large image files (which were around 2 GB) from being pushed with the code, I deleted them manually on the local and then pushed all the changes to the remote branch.</p><p>Despite deleting these large files before making the final push, my remote repository size suddenly shot up to 2.7 GB from a few MBs!!!</p><p>Now, Git has a different way of handling the repository history and deleted files. When you are cleaning your local and remote repo, it is important to not only delete the files but also all the objects that point to these files. Once the files are deleted, these objects become “loose” or “unreferenced” as the files they were pointing to are no longer present in the repository. Git merges multiple objects together and stores them into a single file known as a pack file which is present in the <strong>.git/objects/pack</strong> directory of the repository.</p><p>I noticed that <strong>.git </strong>folder was around 2 GBs by itself and it was this directory that was responsible for the large size of the repo. The objects which were pointing to the deleted image files had to be removed!!</p><p>A very efficient and quick way to tackle this problem was to re-write the history of the repo by deleting all the unreferenced objects.</p><p>Steps to get rid of large files and their corresponding objects on the local and remote repository -</p><ol><li>Clone a copy of your Bitbucket repository on the local and keep it as a backup. Rename this repository to avoid conflicts.</li></ol><pre>git clone &lt;repository-name&gt;.git</pre><p>2. Clone another copy of the same repo on your local and go inside the local working folder.</p><pre>cd &lt;local-repository&gt;</pre><p>3. Go to the branch from which the large commit was made.</p><pre>git checkout &lt;branch-name&gt;</pre><p>2. Delete all the unnecessary files present in that particular directory -</p><pre>git filter-branch --force --index-filter &#39;git rm -r --cached --ignore-unmatch &lt;DIRECTORY-NAME&gt;&#39; --prune-empty --tag-name-filter cat -- --all</pre><p>3. Remove all references to those files from the active history of the repository i.e. remove the references from the <strong>.git</strong> directory</p><pre>git for-each-ref --format=&#39;delete %(refname)&#39; refs/original | git update-ref --stdin</pre><p>4. Remove all the references of unreachable or ‘dangling’ commits in the Reference Logs OR reflog.</p><pre>git reflog expire --expire=now --all</pre><p>5. Perform a GC cycle to force all the references to the large files to be expired and purged from the pack file.</p><pre>git gc --prune=now</pre><p>6. This will clean up the <strong>local repository</strong>. Do not close the terminal.</p><p>7. Log in to your Bitbucket account and click on your profile icon and under SETTINGS<em> </em>select <a href="https://bitbucket.org/account/settings/features/">Labs</a>, then enable the feature <strong>“Delete dangling commits when over size limit”</strong>.</p><p>8. Now, once you enable this feature, push the changes you made on the local for filtering and performing GC.</p><pre>git push --all --force</pre><p>9. Once you push it to the remote, the files that have been deleted on the local repo will become unreachable files/dangling content for the remote, and since you have enabled the feature for GC cleaning on the remote it will clean and prune all unreachable files and also repack the files to compress them into one, thus freeing even more space on the remote repository.</p><p><strong>NOTE</strong> — This is an implemented feature for automatic GC execution that helps users in their personal workspaces. It will not be triggered on the repositories with a shared workspace. Hence, it is important to keep all the users of the repository informed.</p><p><strong>References</strong></p><ol><li><a href="https://support.atlassian.com/bitbucket-cloud/docs/reduce-repository-size/">Bitbucket and Atlassian support for reducing repository size</a></li><li><a href="https://jira.atlassian.com/browse/BCLOUD-11593">Bitbucket repository size-reduction Feature Request</a></li><li><a href="http://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery#Removing-Objects">Git- Maintenance and Data Recovery</a></li><li><a href="https://stackoverflow.com/questions/8740187/git-how-to-remove-file-from-historical-commit">Git- Remove large files from the commit history</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46787ba68011" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>