Not long ago, we have made the switch from SVN to Git.
A few days ago, I realized that all of our team gets those messages when they push :
$ git push Counting objects: 32, done. Delta compression using up to 8 threads. Compressing objects: 100% (19/19), done. Writing objects: 100% (32/32), 2.94 KiB | 0 bytes/s, done. Total 32 (delta 14), reused 0 (delta 0) error: The last gc run reported the following. Please correct the root cause and remove gc.log. Automatic cleanup will not be performed until the file is removed. warning: There are too many unreachable loose objects; run 'git prune' to remove them. To [email protected]:root/xxx.git 15c3bbb..69e6d8b xxxx -> xxx
I thought it was coming from my computer for a while, until I realize that everybody has the same issues.
Needless to say, there is no gc.log in my .git folder, and using 'git gc' or 'git prune' has no effect.
So my question is : Could it be that the repository hosted on the server is somehow not clean? If so, how to I actually clean it?
All of the solutions I have found so far relate to local copies of repositories.
Also, we use Gitlab to host our repos.
EDIT : It is worth saying that I have since I posted this question also tried "Housecleaning" the repository using Gitlab but with no result so far.
Unreachable objects are those that are inaccessible by any refs. Any commit that cannot be accessed through a branch or tag is considered unreachable. git prune is generally not executed directly. Prune is considered a garbage collection command and is a child command of the git gc command.
--prune=<date> Prune loose objects older than date (default is 2 weeks ago, overridable by the config variable gc. pruneExpire ). --prune=now prunes loose objects regardless of their age and increases the risk of corruption if another process is writing to the repository concurrently; see "NOTES" below.
This is followed by issue 14357 (GitLab 8.6- or less)
The manual fix was:
rm gc.log
, this just contained the line " warning: There are too many unreachable loose objects; run 'git prune' to remove them."git prune
and prayed it didn't break things (which it thankfully didn't)But it looks like, starting GitLab 8.7, auto gc is disabled.
This is also done in the context of (still opened) issue 13524:
Typically after a rebase, amend or other action that requires a force push we can have dangled commits.
Such "dereferenced" commits are getting lost due to
git gc
that may be executed internally or by using GitLab Housekeeping features.If it happens that there was a discussion attached to a specific commit - it is not available after dereferenced commit has been garbage-collected.
Commits are being recorded in push events and are available through system notes added to merge request, and currently this produces error 500 in GitLab.
Update: that issue was closed a month later (July 2016) with:
Makes sure a commit is kept around when Git garbage collection runs.
Git GC will delete commits from the repository that are no longer in any branches or tags, but we want to keep some of these commits around, for example if they have comments or CI builds.
I face same issue and above solution did not solve my problem. I was getting the same issue that says :
warning: There are too many unreachable loose objects; run 'git prune' to remove them.
I have refer this link and run the following command it got resolved : git gc
eg : /xx/code/home/xx
is my git repositry home path.
(base) laxman@xxxxx:/xx/code/home/xx$ git gc Counting objects: 251571, done. Delta compression using up to 12 threads. Compressing objects: 100% (78004/78004), done. Writing objects: 100% (251571/251571), done. Total 251571 (delta 141562), reused 245636 (delta 137343)
Hope it will work for some others as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With