Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stopping a git gc --aggressive, is that a bad thing?

Tags:

git

git-gc

I am running a git gc --aggressive on a very large repo (apx 100 gb). It's been running since two nights ago, and as of a couple hours, it has been stuck on: "Compressing Objects: 99% (76496/76777)"

If I Ctrl-C the process, what are the consequences? Will my repo be unusable? My intuition says no, but I'd like some opinions. Thanks!

like image 303
imyjimmy Avatar asked May 20 '11 01:05

imyjimmy


People also ask

What does git gc aggressive do?

What is git gc aggressive? git gc can be invoked with the --aggressive command line option. The --aggressive option causes git gc to spend more time on its optimization effort. This causes git gc to run slower but will save more disk space after its completion.

When should you not run git gc?

See gc. auto below for how to disable this behavior. Running git gc manually should only be needed when adding objects to a repository without regularly running such porcelain commands, to do a one-off repository optimization, or e.g. to clean up a suboptimal mass-import.

How often does GitHub run git gc?

GitHub Support responded to this question on Twitter in 2013. We run git gc at most once per day, triggered automatically by a push.


2 Answers

git is supposed to be always safe from interruptions like this. If you are worried, though, I suggest Ctrl+Z and then run a git fsck --full to make sure the system is consistent.

There are a number of git-config variables which might help your git-gc go faster. I use the following on one particular large repo, but there are many more options to randomly try (or carefully study, whichever).

git config pack.threads 1 git config pack.deltaCacheSize 1 git config core.packedGitWindowSize 16m git config core.packedGitLimit 128m git config pack.windowMemory 512m 

These only help if your problem is that you are running out of memory.

like image 131
Seth Robertson Avatar answered Oct 05 '22 16:10

Seth Robertson


FWIW, I just corrupted a repository by aborting git gc with CTRL+C. git fsck now shows the following errors:

error: HEAD: invalid sha1 pointer [...] error: refs/heads/master does not point to a valid object! notice: No default references 

And quite a few

dangling commit [...] 

I'm not going to investigate on this, but I would like to point out that I'm going to avoid aborting git gc.

like image 28
Malte Clasen Avatar answered Oct 05 '22 15:10

Malte Clasen