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?
- 66,715
- 58
- 275
- 411
3 Answers
I know that Github will run git gc periodically as the Github support mentions in this thread.
I don't know if you can force it yourself though.
I didn't see such a service in the Github hooks.
- 1,129,465
- 480
- 4,036
- 4,755
-
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
-
So 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
I believe that pushing your changes will only add new commits (as necessary to reach the branches you are pushing); it will not delete them. This is corroborated by this github support page on deleting sensitive data:
Be warned that force-pushing does not erase commits on the remote repository, it simply introduces new ones and moves the branch pointer to point to them. If you are worried about users accessing the bad commits directly via SHA1, you will have to delete the repository and recreate it.
So if you can't wait for GitHub's periodic gc, then you have to recreate.
- 15,695
- 12
- 82
- 107
-
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
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,184
- 1
- 28
- 23