Does Github COPY a forked repository, or use some other techinque to save on disk usage?

Hi there,

I am (idly) wondering if Github stores a full copy of a .git folder when a user forks a repository. A friend of mine postulated that surely there is some smarter implementation at work here that avoids replicating the full history of commits in a fork, but I believe (Occam’s razor) that Github would just take the disk usage hit and copy the .git folder verbatim, altering the remote aspects of the (user) repository to point to the original repo.

If anyone has some inside understanding of the implementation I would love to know how Github implements it.



Hello @kurtlawrence and welcome to the community.

No, when you fork a repository on GitHub, it does not create a separate copy of the original repository as far as the underlying git repository is concerned. You can verify this in a couple different ways including that when you create a new commit in a fork, there are ways that you can view that commit as if it is a commit in the original repository even though if you looked through the branches of the original repo in the GitHub UI you would not see that commit listed.

Please keep in mind that this is an implementation detail that could be changed at any time. I’m simply sharing the information for educational purposes :grinning:

1 Like