Reputation: 10882
In preparation for a commit, I git add file f twice, only using it in its 2nd version with the commit. Can I remove version 1 of f from .git/objects? Does .git/objects contain "useless" copies of my git adds even when intermediate versions aren't ever committed? How can I do some clean-up?
Upvotes: 0
Views: 65
Reputation: 258358
git gc will run automatically for "some commands", but it also says:
Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.
git gc will prune 2-week-old unreachable objects by default, but you can override that duration with the --prune
option.
To specifically only remove unreachable objects, you can use git prune. From its notes:
In most cases, users will not need to call git prune directly, but should instead call git gc, which handles pruning along with many other housekeeping tasks.
For a description of which objects are considered for pruning, see git fsck's
--unreachable
option.
Upvotes: 3