It seems like git gc --aggressive
really cleans up my repo, but when I do git push
everything is already up-to-date. Is there a way to clean up the server?

- 68,471
- 58
- 283
- 421
3 Answers
2012: I know that GitHub will run git gc
periodically, as the GitHub support mentioned in this thread.
Since 2012 (up to 2023):
I don't know if you can force it yourself, though.
I didn't see such a service in the GitHub hooks.
As illustrated by "How to remove a dangling commit from GitHub?", no git gc
seems to be ever performed on remote GitHub repository.
That means any remote repository cleanup would be the result of an explicit request to GitHub Support.

- 1,262,500
- 529
- 4,410
- 5,250
-
On Unfuddle it's weekly, apparently: http://unfuddle.com/community/forums/4/topics/6ee44a Let's hope it's more often than that by now. Thanks! – Dan Rosenstark Feb 04 '12 at 17:07
-
http://metalinguist.wordpress.com/2007/12/06/the-woes-of-git-gc-aggressive-and-how-git-deltas-work/ – Dan Rosenstark Feb 04 '12 at 17:54
-
@Yar interesting link on gc --aggressive. I guess only Github support has a definitive answer. – VonC Feb 04 '12 at 18:34
-
1So what happens on a server-side repo if `gc` is never run? Old objects just collect and never get cleaned up, even when they're orphaned? – Dan Rosenstark Feb 05 '12 at 08:36
-
1@Yar that is the idea, but I don't think any service in charge of storing repositories would remove that feature – VonC Feb 05 '12 at 10:02
-
@spamove Thank you for this update. I have included your comment in the answer for more visibility. – VonC Mar 03 '23 at 12:02
-
@spamove No problem. I have updated the answer accordingly. – VonC Mar 03 '23 at 13:46
Github doesn't seem to clean up anything for you:
Warning: This article tells you how to make commits with sensitive data unreachable from any branches or tags in your repository on GitHub.com. However, those commits may still be accessible in any clones or forks of your repository, directly via their SHA-1 hashes in cached views on GitHub, and through any pull requests that reference them. You cannot remove sensitive data from other users' clones of your repository, but you can permanently remove cached views and references to the sensitive data in pull requests on GitHub by contacting GitHub Support.

- 17,394
- 14
- 91
- 115
-
Note that the linked-to page no longer contains this section or (as far as I see) an equivalent warning. I don't know if that means that they now more aggressively purge unreachable SHA-1s or simply removed the warning. – Joachim Sauer Apr 26 '21 at 09:25
-
no gc is run on GitHub's side: https://stackoverflow.com/questions/4367977/how-to-remove-a-dangling-commit-from-github/4368673#4368673 ; the discussion linked is outdated (and 404 right now); even support pages say that dangling commits stay – spamove Mar 03 '23 at 11:18
-
You'll have to run the same command on the server side as well. Most people just set up a cron job or similar to do this sort of housekeeping periodically.

- 4,462
- 1
- 30
- 23
-
8
-
1@DanRosenstark it's completely vendor-dependent. Most (at least GitHub and GitLab) doesn't do git GC by default due to compatibility reasons. In some settings you can do that manually, https://stackoverflow.com/questions/37207711/how-can-i-force-gitlab-to-carry-out-a-garbage-collection-and-permanently-remove – spamove Mar 03 '23 at 11:20