idanshmu
idanshmu

Reputation: 5251

Keep .git directory small

Background

I have a window service that generates git branch (commit) every 10 minutes. Each commit is pushed to the server. Each commit contains hundreds of files with significant difference from the previous version. The service run non-stop.

Problem

after several days/weeks, .git directory size increases dramatically (15GB) and my drive overflows. I have no problem the server increase monotonically, BUT I'd like to keep the local machine drive usage as limited as possible.

Question

Is there a nit git command to clear all the local data (branches, tags, etc.)

Suggestion

I could easily remove the entire git directory, including .git directory and have the service clone the git repository each time it runs (every 10 minutes). But I'm afraid clone operation may slow down the entire operation. So, I'm looking for a better approach.

Upvotes: 1

Views: 119

Answers (1)

VonC
VonC

Reputation: 1323115

I don't need my local machine to "remember" all repository's history. By removing the the entire git dir and re-cloning it, the dir is at minimal & satisfying state.
I assume I can use a git command to simulate the remove-dir-and-reclone operations

The remove would not involve a git command, just a simple rm -Rf.

The clone could take advantage of a shallow clone:

git clone --depth 1 remote-url

Upvotes: 1

Related Questions