Chris Hansen
Chris Hansen

Reputation: 8661

git taking a long time to load

So I pulled a large number of files using git once (massive).

But then I used git rm to remove the directory from the git database because git started taking a long time to pull from origin, but calling git rm did not solve the problem - git still takes a long time to pull from origin.

What can I do other than recreating the repository to fix this problem?

Upvotes: 2

Views: 2244

Answers (2)

Ben
Ben

Reputation: 21249

Because git keeps a history of all your commits, that content is technically there in the git repo (which, thankfully is exactly what a source repo is good for :)

You can rewrite the past history to remove all references to the folder.

This site has an example using filter-branch:

http://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-a-git-repository

Note: You are rewriting history, you will need to force push the repo to the server. If other people are using/committing to it, it may cause them some trouble.

Edit: Another interesting read on the topic: http://ramblinglabs.com/blog/2012/04/git-removing-sensitive-data-and-rewriting-history

Upvotes: 2

Blake Taylor
Blake Taylor

Reputation: 9341

git rm won't actually remove large objects which were at any point committed in the current history of any head you have referenced in your repository (e.g. branch, tag, etc.)

I'm not sure if this is what's causing git to pull slow (in my experience, once you've pull a large difference, things should be back to fast and normal on subsequent pulls), but if you suspect it, you can try completely removing the commits, which contain large differences, with git rebase.

Once you've done that, you can do a git gc to clean up the detached objects from you repo and reduce the overall size. To rsync with you're remote repo you will need to do a force push.

Upvotes: 0

Related Questions