Git - There are too many unreachable loose objects

Search for a command to run...

No comments yet. Be the first to comment.
PostgreSQL Upgrade and Database Restoration Guide To support the pgvector gem, I upgraded my local Postgres.app from v13 to v17 on macOS. Below is the full upgrade and restoration process for my project. Environment OS: macOS PostgreSQL: Upgraded f...

Introduction In Ruby on Rails applications, handling database transactions efficiently is crucial to maintaining data integrity. One common issue developers face is dealing with runtime errors caused by unpersisted changes when using the with_lock me...

Environment MacOS Sonoma 14.3 Original Ruby version: 2.7.8 Ruby Version Manager: RVM 1.29.12 Goal Upgrade Ruby from 2.7.8 to 3.0.6. Issues Description After successfully installing Ruby 3.0.6, I encountered difficulties running bundle install in...

It is common to see require 'something' in a Rails application. But what exactly does require do? What is require used for in Ruby? require is used to load external libraries or modules into your program. For example, Before you require the JSON modu...

In my daily job, I mainly use Rails framework. To make code readable and maintainable, we seldom write raw SQL in the codebase. Instead, we use Rails's ActiveRecord::QueryMethods module which helps developers write beautiful queries quickly. For exam...

git cm 'some_message'
commit successfully, but git showed the message below:
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.
You are seeing this error because you have too many dangling commits for git to automatically clean up.
Dangling objects exist but they are never directly used.
A change that made it to the staging area/index but never got committed.
A commit isn’t directly linked to any child commit, branch, tag, or other references.
(Information from: Stack overflow)
Actually, the worst situation is dangling objects take up too much space of the hard disk.
git fsckThis will verify the connectivity, validity of the object and list those dangling objects if they exist.
2. git gc --prune=now
git pruneThis will remove dangling objects.
git gc-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. — prune is on by default.
Reference: