Commit id changed to 11 digits from 7 digits.

I moved a git repository present in one stash instance to another by first cloning it using git clone --mirror command and then using git push --mirror command. 

After doing so, I noticed that commit id has changed to 11 digits in new stash instance instead of 7 digits present earlier.

The new format seems like to be the <old_7_digit>+<new_4_digit>.

Can you please let me know the reason behind this?

2 answers

1 accepted

My commit hashes are 40 digits long. the short versions still 7 (git bash command line).

The short versions are for display only, you should not rely on their length. Where do you have a problem with this?

The length of the short version is typically chosen so that you do not have collisions / duplicates in large projects. I just checked our Stash and it also has 11 digits for the short hash. You will note that this is used for a nicer display only, when you click on such a hash code link, it uses the long form in the link and internally.

Please see this:

https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#Short-SHA-1

1 vote

Hello Rajat,

Thank you for your inquire.

Could you please let us know:

  1. I noticed that commit id has changed to 11 digits in new stash instance instead of 7 digits present earlier., Where have you noticed that change (Stash UI)?
  2. what is the Stash version (Origin)
  3. what is the Stash version (Destination)

I have ran the following commands in attempt to replicate the issue:

stash.original.png

$ git clone --mirror ssh://git@stash:7999/mir/original.git
Cloning into bare repository 'original.git'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
Checking connectivity... done.
$ cd original.git
 
$ git push --mirror ssh://git@stash:7999/mir/mirror.git
Counting objects: 3, done.
Writing objects: 100% (3/3), 217 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 3 (delta 0)
To ssh://git@stash:7999/mir/mirror.git
 * [new branch]      master -&gt; master

stash.mirror.png

Please, notice if you run "git log" from either ORIGINAL or MIRROR the hash should be the same and this is what matters:

$ git log
commit 76b2ace641b92e67ac16db7daf28125b7533499b
Author: Administrator &lt;administrator@hostname&gt;
Date:   Wed Dec 16 18:06:43 2015 -0200
    add foo

 

Kind regards,
Rafael P. Sperafico
Atlassian Support

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,753 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you