Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Can a commit with the same hash be created/restored using the Bitbucket API?

Our objective is to find a backup solution for Bitbucket. Is it possible to create or restore the exact same commit hash?

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Nov 07, 2023

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

Hello @Patrik S ,

Thank you for your reply. Based on the commit, it is known that those files should be assigned to that specific branch.
In order to restore the files, it is necessary to provide the commit hash.

Like Sabine Mayer likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events