Our objective is to find a backup solution for Bitbucket. Is it possible to create or restore the exact same commit hash?
Hello @Nagaraja and thank you for reaching out to Community!
As per what is described in How git sha1 is created the following information is used by git to generate a commit hash :
- The source tree of the commit (which unravels to all the subtrees and blobs)
- The parent commit sha1
- The author info (with timestamp)
- The committer info (right, those are different!, also with timestamp)
- The commit message
So won't be able to exactly recreate the same commit hash as several variables, such as the commit parents, the date of the commit, and the author will influence the generated hash of the new commit.
Could you elaborate more on why would you like to recreate a commit with the same SHA?
If you are looking to back up your repositories, we would suggest executing a mirror clone of it:
git clone --mirror <repository URL>
as it will include all the objects/references that are stored in the remote end.
Let us know in case you have any questions.
Thank you, @Nagaraja !
Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.