2

There is a GitHub repository with many commits. I want to ensure that I can access the repository even if its owner decides to delete it. Moreover, I need access not only to its present state but also to all its past commits.

If I just fork the repository, will this guarantee that I can access all its present and past commits?

NOTE: the question "Are git forks actually git clones?" is about the connection between forks and clones, but it does not answer what happens to a fork when the original project is deleted - does the fork keep all history of the original?

Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
  • Possible duplicate of [Are git forks actually git clones?](https://stackoverflow.com/questions/6286571/are-git-forks-actually-git-clones) – Ben Jun 17 '18 at 04:49
  • Possible duplicate of [How is Git Distributed Source Code Management?](https://stackoverflow.com/questions/2366760/how-is-git-distributed-source-code-management) See answers to the linked question. – tkruse Aug 20 '18 at 14:06

2 Answers2

2

Yes. If the original repository gets deleted, then the fork keeps all its commits, including the past commits.

However, you will loose the line saying Forked from <User name>/<repository name>, i.e. there will be no more link to the original, now deleted, repository on GitHub.

Striezel
  • 3,693
  • 7
  • 23
  • 37
  • Yes, but there is no guarantee that the github repository has all project commits. Many projects rewrite history before pushing to github and you will not get those commits. – emory Jun 17 '18 at 12:36
  • @emory Of course not, but those commits were not part of the forked repository in the first place, since they never have been published to GitHub. So I think that is a non-issue here. – Striezel Jun 17 '18 at 12:38
  • It could be an issue for the OP, depending on what he/she is trying to do and how history was rewritten. There could be binary releases for which the OP does not have the source code. – emory Jun 17 '18 at 12:46
0

You keep the whole past history up to the present, but if new commits are added to the original repository after you forked it, you would not get those new commits (unless you fetched them).

tkruse
  • 10,222
  • 7
  • 53
  • 80