Reputation: 170499
Most of my source control experience is with Subversion and there (unless you use admin mode deletion features which you typically don't) all commits made to a repository are preserved for the life of the repository.
I'm not sure the same is true for Github. For example, this post talks about some reflog thing and some prune thing that presumably can delete some data in irrevocable way.
Assuming the repo to which a commit was pushed isn't deleted can I be sure that the commit is never lost in irrevocable way?
Upvotes: 1
Views: 427
Reputation: 1323963
Once the commit is made, it has a sha1 that will be the same once you push that commit to the GitHub repo.
And any clone of that GitHub repo will be able to look for that same SHA1 to be sure this commit is still there.
In Git Basics:
Everything in Git is check-summed before it is stored and is then referred to by that checksum. This means it’s impossible to change the contents of any file or directory without Git knowing about it. This functionality is built into Git at the lowest levels and is integral to its philosophy. You can’t lose information in transit or get file corruption without Git being able to detect it.
The mechanism that Git uses for this checksumming is called a SHA-1 hash.
This is a 40-character string composed of hexadecimal characters (0–9
anda–f
) and calculated based on the contents of a file or directory structure in Git.
A SHA-1 hash looks something like this:
24b9da6552252987aa493b52f8696cd6d3b00373
Actually, the SHA1 of a commit is also based on the parent(s) of said commits: you can't change the history in the past without affecting all subsequent commits.
reflog
only comes in the picture if you overwrite the history on GitHub with a git push --force.
In that case, GitHub support has access to the local reflog of the GitHub repo, and can restore that commit which is no longer referenced by any branch or tag (hence its presence in the reflog).
Update: or the repo owner can query the GitHub Events API:
See "Does GitHub remember commit IDs?"
Upvotes: 1