Note that there are some explanatory texts on larger screens.

plurals
  1. PORemoving unwanted files from history including all refs with filter-branch
    text
    copied!<p>I recently have cloned an SVN repository which used to have a few binaries in it, which are not needed any longer. Unfortunately, I have already pushed it to Github with the binaries inlcuded. I now want to remove these using 'git filter-branch' but I am facing some problems when it comes to tags and branches.</p> <p>Basically, I have created a simple shell script to remove a list of files which have been determined by the following command:</p> <pre><code>git rev-list --objects --all | grep .jar &gt; files.txt </code></pre> <p>The script for removal looks like the following:</p> <pre><code>#!/bin/sh while read file_hash file_to_remove do echo "Removing "$file_to_remove; git filter-branch --index-filter "git rm --cached --ignore-unmatch $file_to_remove" rm -rf .git/refs/original/; git reflog expire --all --expire-unreachable=0; git repack -A -d; git prune done &lt; $1 </code></pre> <p>I have a few tags (all listed in .git/packed-refs), one .git/refs/remotes/origin (pointing to the Github repo). The removal of the files using the above script does not have the wanted effect ('du -cm' remains to output the same size; 'git rev-list' still listing the files) until I manually remove all references from .git/packed-refs and the .git/refs/remotes/origin directory.</p> <p>Naturally, I am losing all tags as well as the possibility to push my local changes back to Github with this approach. Is there anything I have missed or is there an alternative way for removing files from all branches/tags without destroying my history?</p> <p>Many thanks in advance, Matthes</p>
 

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