Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove file from git repository (history)
    primarykey
    data
    text
    <p>(solved, see bottom of the question body)<br> Looking for this for a long time now, what I have till now is:</p> <ul> <li><a href="http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/" rel="noreferrer">http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/</a> and</li> <li><a href="http://progit.org/book/ch9-7.html" rel="noreferrer">http://progit.org/book/ch9-7.html</a></li> </ul> <p>Pretty much the same method, but both of them leave objects in pack files... Stuck.<br> What I tried:</p> <pre><code>git filter-branch --index-filter 'git rm --cached --ignore-unmatch file_name' rm -Rf .git/refs/original rm -Rf .git/logs/ git gc </code></pre> <p>Still have files in the pack, and this is how I know it: </p> <pre><code>git verify-pack -v .git/objects/pack/pack-3f8c0...bb.idx | sort -k 3 -n | tail -3 </code></pre> <p>And this:</p> <pre><code>git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch file_name" HEAD rm -rf .git/refs/original/ &amp;&amp; git reflog expire --all &amp;&amp; git gc --aggressive --prune </code></pre> <p>The same...</p> <p>Tried <code>git clone</code> trick, it removed some of the files (~3000 of them) but the largest files are still there...</p> <p>I have some large legacy files in the repository, ~200M, and I really don't want them there... And I don't want to reset the repository to 0 :(</p> <p>SOLUTION: This is the shortest way to get rid of the files:</p> <ol> <li>check .git/packed-refs - my problem was that I had there a <code>refs/remotes/origin/master</code> line for a remote repository, delete it, otherwise git won't remove those files</li> <li><em>(optional)</em> <code>git verify-pack -v .git/objects/pack/#{pack-name}.idx | sort -k 3 -n | tail -5</code> - to check for the largest files</li> <li><em>(optional)</em> <code>git rev-list --objects --all | grep a0d770a97ff0fac0be1d777b32cc67fe69eb9a98</code> - to check what are those files</li> <li><code>git filter-branch --index-filter 'git rm --cached --ignore-unmatch file_names'</code> - to remove a file from all revisions</li> <li><code>rm -rf .git/refs/original/</code> - to remove git's backup</li> <li><code>git reflog expire --all --expire='0 days'</code> - to expire all the loose objects</li> <li><code>git fsck --full --unreachable</code> - to check if there are any loose objects</li> <li><code>git repack -A -d</code> - repacking</li> <li><code>git prune</code> - to finally remove those objects</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload