Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

SourceTree: Obliterating large files from a Git repository

Alex Rodrigues August 20, 2014

Our git repository is around 2GB and when cloned accounts for around 3GB due to the checkout in the workspace. I know there are a couple of very large binaries that may have been deleted form version control in the past but still exist in the repository.

Is there a way using either SourceTree or Stash to identify and/or delete these files?

1 answer

1 accepted

0 votes
Answer accepted
Johannes Kilian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 24, 2014

Hmmmm ... as those files are part of the history of your project they shold not be removed from the repository - doing so you won't be able to checkout a complete historical version of your software (as the files you removed finally are not part of the repository anymore).

Usually removing files from the repository is only done when those files were added by accident and you are completly sure you don't need them - even in historical versions of your software. If you say, "I don't need the files anymore" this involves you needed the files earlier - and therefore the files should not be removed (as you cannot reconstruct them)

Removing files from the repository is a git task - and therefore not part of stash. Sourcetree does not offer this as well - you have to do this on comand-line using the command

git filter-branch --tree-filter ....

as for example described here.

The best way to do this, is cloning your repository from stash and performing the git-filter action on your local clone. After approval that your local repository looks fine, you should remove the "huge" repository from STASH and re-push the modified repository. After this you have to be sure that all of your coworkers remove their old local copies of the repository and clone the modified one!

If your main concern is the size of the repository to clone (2-3GB) you should consider to do a shallow clone (as for example described here). A shallow clone allows you to clone a repository keeping only the latest n commits of history. Therefore you can omitt those large historical files from cloning - with the drawback not to have the complete history of your project locally available.

Alex Rodrigues August 24, 2014

Thanks Johannes.

Yes, the large files I would like to delete were added accidentally and are not being used at all. Thanks you for the link that explains how to go about with removing the files.

Shallow clones may not be for us as it has some limitations about committing changes to that type of clone.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events