Problem with Git repository size

5

In the company where I work, I was using Git to save a system, where three people use it.

After an image folder has been accidentally sent, making a git pull has become absurd since the downloaded data is almost 1.6GB.

We later removed this folder from images through the file .gitignore . However, even after this change, the repository continues to be very large.

I have some questions to ask about this:

  • How to reduce the size of a Git repository (when an accident occurs as above)?

  • Is there any way to get a git pull or a git fetch , ignoring some files, such as images and / or videos (via parameters or something like that)?

  • Why, even after deleting large files and adding them to .gitignore , is Git still giant? Are ignored (previously added) part of history?

  • And, if "yes" to history, is there any way to delete these unwanted files from history?

asked by anonymous 10.04.2015 / 16:32

2 answers

5

Probably what you want is to rewrite the history of your repository, which can be problematic if you do not know what you are doing (I do not know: P). this is done with filter-branch . An example:

git filter-branch --tree-filter 'rm -rf path/file' HEAD

You may need adaptations, as needed, for this to read the documentation.

You can also delete a commit and make a rebase but I think it would be more complicated.

    
10.04.2015 / 16:46
4

You can make a cherry-pick and remove or undo a patch .

Here has a good explanation of the cherry-pick and here has a question answered that closely resembles your problem.

I suggest a lot of quiet at this time to not remove anything beyond what is necessary.

    
10.04.2015 / 17:04