Questions tagged [git-gc]

The `git gc` function is used to perform housekeeping in a Git repository, run automatically by certain other Git operations, or manually.

General information

This function performs a number of housekeeping operations on a Git repository, including compressing file revisions and removing unreachable objects.

There are three main modes of operation:

  • Automatic. Certain Git commands will run git gc --auto, which will attempt to determine whether clean-up is necessary, and perform it if so. Automatic housekeeping can be disabled by running git config gc.auto 0.

  • Manual. You can run git gc from the command line whenever you like. This is particularly important if you've disabled the automatic operation as above.

  • Aggressive. Running git gc --aggressive will perform a much slower and more thorough optimization. The Git man pages recommend doing this only "every few hundred changesets or so", since the effects are persistent.

See also the Git man page for git gc.

On Stack Overflow

The "git-gc" tag should be used for anything to do with this command: when to run it, how to run it, how to resolve problems with running it or caused by running it, and how to configure how it works.

61 questions
1
vote
1 answer

Mirror Gerrit maintained Git repositoty

I have a bare repository A.git with 1500 branches not under Gerrit and resides in Host 1 I have a the same bare repository A.git with 2000 branches under Gerrit and resides in Host 2 The 500 extra branches in A.git under Gerrit might be branches…
Senthil A Kumar
  • 10,306
  • 15
  • 44
  • 55
1
vote
1 answer

git gc failure refers to object hash that's not referenced anywhere

Recently, I noticed that when I've been git pulling my repo, it's been doing a git gc every single time. So I tried to run git gc manually, which gave me this error: fatal: bad object 76cab35e0e21b7cf0bc8416661a67fbfb7f0e4ba error: failed to run…
jiangty
  • 311
  • 2
  • 9
1
vote
0 answers

Repack borrwed repo everytime while using alternates?

I'll ask the question first and then give explanation: What will be the problems if my pack-file is very huge, say 100-150Mb? What am I doing? I have created a forking model for my organization. So every developer forks from blessed_repo, clone…
Mudassir Razvi
  • 1,783
  • 12
  • 33
1
vote
1 answer

git: repack locally, push the repacked objects

Is there any way for me to do the repack work on the local machine, then push the resulting packed database to my remote repository?
bukzor
  • 37,539
  • 11
  • 77
  • 111
1
vote
2 answers

Setting variables on git remote repository - git gc doesn't run automatically

It seems that git refuse to do gc command automatically on my remote repository. In about one month that repository enlarge to about 6GB because of .pack files. I think that is problem with variable gc.auto - how can I set this variable on remote…
Seblis
  • 339
  • 4
  • 17
0
votes
0 answers

Undoing garbage collection

Recently i was working on a project with two other guys, now i encountered an error when i was trying to pull making commits to my local work, after checking stackoverflow i was advised to to do git gc,( garbage collection), i was able to pull after…
Jonas
  • 1
  • 1
0
votes
1 answer

Does git gc actually increase the disk usage in any case?

I have a mirror cloned repository on which I wanted to try git gc. When I check the disk usage before and after using git gc, it actually increase the usage. Will there be any case in which it actually increases the usage?
Underoos
  • 4,708
  • 8
  • 42
  • 85
0
votes
3 answers

git recreate refs/heads/master after gc

after I run git gc --prune=now the file .git/refs/heads/master is deleted how to recreate it? a remote application needs to read its text content (commit hash) .git/HEAD content : ref: refs/heads/master
geek175
  • 127
  • 1
  • 7
0
votes
1 answer

Repo still uses 8 GB of quota after force push to initial commit (empty repo)

My gitlab repo was ~8GO To rewrite it completely with size optimisation the idea was to reset the remote to the first commit and force push (git checkout ; git push -f) Then rewrite the history locally reducing size with compression…
ATX
  • 1,139
  • 2
  • 11
  • 29
0
votes
1 answer

Reducing .git folder size in case of using github as a blockchain snapshot repository

I have created a repository on GitHub with the snapshot of the blockchain database folder that I am updating every day by command: git pull git fsck git prune git add . dt=$(date '+%d/%m/%Y'); git commit -a -m "$dt" git push This repository later…
Skuld
  • 13
  • 2
0
votes
1 answer

Reducing git pack size with removing binary files

The repo is containing folder with binary files and that causes increasing the pack size in .git folder, now .git is ~800MB (80% of total size) and repo size is 1GB. I've tried to delete the folder and commit it and do all these git gc, git fsck,…
MK83
  • 1,652
  • 1
  • 11
  • 11
0
votes
2 answers

git push and unreferenced objects

Without running git prune or git gc, will git push upload any unreferenced objects? Imagine these commits history: A <= B <= C <= D <= E where in commit C a new file was added, and that file deleted from commit D. Now a git rebase --onto B D will…
doc_id
  • 1,363
  • 13
  • 41
0
votes
1 answer

Repack after importing from svn

I have imported with svn2git a SVN Repo. Now I left with the choice how to repack/garbage collect the repo to reduce the size, but I dont want to sacrifice the performance of later git operations. How do I do that? The homepage of the tool suggests:…
Gabriel
  • 8,990
  • 6
  • 57
  • 101
0
votes
2 answers

Test Git repo size reduction after deleting a branch

Is there any way I can test how the deletion of several branches will affect the size of that git repo. I have a git repo with 10 lived branches and hundreds of feature (short lived branches). The repo is very large and slow to clone. GitLab shows…
ptha
  • 836
  • 1
  • 8
  • 22
0
votes
2 answers

Is git gc required for a mirrored git bare repository where user's don't push any changes

I have a git bare repository named "master.git" where i regularly run "git gc --prune=now" at regular intervals. I have another git bare repository named "slave.git" which is created with the --mirror option from "master.git". But i have stopped…
Senthil A Kumar
  • 10,306
  • 15
  • 44
  • 55