Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8314481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:49:56+00:00 2026-06-08T20:49:56+00:00

My opinion is that it should be possible to get a duplicate git hash

  • 0

My opinion is that it should be possible to get a duplicate git hash because the hash code is a condensed representation of uniqueness thus there will be some sequence of steps that produces the same hash code. More importantly there should be a sequence of steps where different changes are committed yet produce the same hash code.

For example clone the same repository twice on the same machine, making almost the same exact change (save one byte or bit) in the different repositories and committing. Even if the directory name or timestamp is used in the commit, it should still be possible to get this (though granted rare). For example two separate people on two different machines making a commit at the same time.

My question is two fold. How can this happen and how will Git handle it.

Or more explicitly how does git ensure you are up to date before a push. Is it possible that one person pushes first, then the other tries to push (both changes based off of the same parent commit) and Git sees that the hash codes match from the remote and local history, decides you are good to go, allows your push but you just lost one of your changes? In this situation i see it more like the following:

repo1
a->b->c1

repo2
a->b->c1′->c2

say c1,c1′,c2 all happen after both repos were cloned at b,
now repo1 pushes, no problems
now repo2 attempts to push c1′ and c2 and git determines that c1′ = c1 but in fact they differ, git pushes c2 ontop of c1 to get
a->b->c1->c2
and we lost the change made in c1′

Is this possible? how could it happen and what would git do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:49:57+00:00Added an answer on June 8, 2026 at 8:49 pm

    With regard to the part of your question that relates to duplicate hashes:

    Git relies completely on the uniqueness of the hashes that are generated, and as far as I know has no safeguards to handle different data blobs yielding the same hash value. However, the chances of a hash collision occurring are vanishingly small and in practice can be ignored. If you are still worried, this section from Pro Git may put your mind at rest:

    A higher probability exists that every member of your programming team will be attacked and killed by wolves in unrelated incidents on the same night.

    As for the second part of your question (what happens):

    If you do happen to commit an object that hashes to the same SHA-1 value as a previous object in your repository, Git will see the previous object already in your Git database and assume it was already written. If you try to check out that object again at some point, you’ll always get the data of the first object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What Linux shell should I use? I am starting to get proficient
Perhaps the Question isnt that simple to answer... but what is your opinion? Should
I would like to get your opinion on which of the following routines should
It is my opinion that every language was created for a specific purpose. What
It seems to be a mainstream opinion that assembly programming takes longer and is
It seems to be the prevailing opinion that using protected data members is a
a point of architectural style that I'd like your opinion on please: My ORM
It seems that one, in my opinion mandatory method is missing from TValue; TValue.Equals(TValue).
I am interested in your opinions on unit-testing code that uses Corba to communicate
Please your opinion on the following code. I need to calculate the diff in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.