Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reduce server git repo size when delete a branch

Tags:

git

github

I have use gitlabhq configed a git server. All Repos save in /repos/ directory at server.

I have a project, and have a branch, this branch have big files. For save disk space, i delete this branch use git push origin :test.

But when i go to my git server, found this project repo size not change.

So my questions is how to reduce server git repo size when delete a branch?

I have used git filter-branch --tree-filter 'rm -f bigfile.zip' HEAD, also seems can not reduce server git repo size.

like image 538
Grant Chen Avatar asked Dec 02 '13 07:12

Grant Chen


People also ask

Does deleting branches reduce repository size?

Deleting files in a commit doesn't actually reduce the size of the repo since the earlier commits and blobs are still around. What you need to do is rewrite history with Git's filter-branch option.

How do I make my git repository smaller?

remove the file from your project's current file-tree. remove the file from repository history — rewriting Git history, deleting the file from all commits containing it. remove all reflog history that refers to the old commit history. repack the repository, garbage-collecting the now-unused data using git gc.

Does git branch take up space?

You git branches don't take space. That is, if you remove one of your branches you usually don't remove much content (even without taking into account compression).


1 Answers

I have resolved it by run below command in server.

bash git gc --aggressive --prune=now

like image 173
Grant Chen Avatar answered Oct 12 '22 09:10

Grant Chen