Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can remove the binary bloat and keep the rest of your history. Git allows you to reorder and 'squash' prior commits, so you can combine just the commits that add and remove your big binary files. If the adds were all done in one commit and the removals in another, this will be much easier than dealing with each file.</p> <pre><code>$ git log --stat # list all commits and commit messages </code></pre> <p>Search this for the commits that add and delete your binary files and note their SHA1s, say <code>2bcdef</code> and <code>3cdef3</code>.</p> <p>Then to edit the repo's history, use <code>rebase -i</code> command with its interactive option, starting with the parent of the commit where you added your binaries. It will launch your $EDITOR and you'll see a list of commits starting with <code>2bcdef</code>:</p> <pre><code>$ git rebase -i 2bcdef^ # generate a pick list of all commits starting with 2bcdef # Rebasing zzzzzz onto yyyyyyy # # Commands: # pick = use commit # edit = use commit, but stop for amending # squash = use commit, but meld into previous commit # # If you remove a line here THAT COMMIT WILL BE LOST. # pick 2bcdef Add binary files and other edits pick xxxxxx Another change . . pick 3cdef3 Remove binary files; link to them as external resources . . </code></pre> <p>Insert <code>squash 3cdef3</code> as the second line and remove the line which says <code>pick 3cdef3</code> from the list. You now have a list of actions for the interactive <code>rebase</code> which will combine the commits which add and delete your binaries into one commit whose diff is just any other changes in those commits. Then it will reapply all of the subsequent commits in order, when you tell it to complete:</p> <pre><code>$ git rebase --continue </code></pre> <p>This will take a minute or two.<br> You now have a repo that no longer has the binaries coming or going. But they will still take up space because, by default, Git keeps changes around for 30 days before they can be garbage-collected, so that you can change your mind. If you want to remove them now:</p> <pre><code>$ git reflog expire --expire=1.minute refs/heads/master #all deletions up to 1 minute ago available to be garbage-collected $ git fsck --unreachable # lists all the blobs(files) that will be garbage-collected $ git prune $ git gc </code></pre> <p>Now you've removed the bloat but kept the rest of your history.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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