git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git behaviour question regarding SHA-1 and commits

From
VVvinassa vinassa <vinassa.vinassa@gmail.com>
Date
Nov 13, 2011, 17:04 UTC
Message-ID
<CAJuRt+r9BjYcead6hgzdUT0Bisz1D48cegqkoJ0S537VMYBy_g@mail.gmail.com>
Hello,

I am relatively new to git; I have only used it to track other git projects, and sometimes to format and send patches to them, but never to handle my own projects.

Now I am considering using git for my next task at work.

I am wondering about how git behaves currently, if I kinda win the lottery of the universe, and happen to create a commit with a SHA-1 that is already the SHA-1 of another commit in the previous history. However improbable.

Would that be detected, so that I could just add a newline, and then commit with a different resulting SHA-1, would I just lose one of those commits (hopefully the new one), would I end up with a corrupted repository?

I found some mention of this in the archive, more about SHA-1 security implications, that were dismissed, but here I am looking at just a random, very unfortunate case, and just wondering if in this case I would end up in a FUBAR situation.

Thank you,
Vinassa
Next: Ævar Arnfjörð Bjarmason
Message 1 of 11 in “git behaviour question regarding SHA-1 and commits”
  1. vinassa vinassaNov 13, 2011
  2. Ævar Arnfjörð BjarmasonNov 13, 2011
  3. Junio C HamanoNov 14, 2011
  4. Jeff KingNov 14, 2011
  5. Jonathan NiederNov 13, 2011
  6. vinassa vinassaNov 13, 2011
  7. Jeff KingNov 14, 2011
  8. Victor EngmarkNov 14, 2011
  9. Jeff KingNov 14, 2011
  10. Dmitry PotapovNov 13, 2011
  11. Johannes SixtNov 14, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.