git中的哈希碰撞 [英] Hash collision in git

查看:218
本文介绍了git中的哈希碰撞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在使用git时发生散列冲突,会发生什么?

例如,我设法使用相同的sha1校验和提交两个文件,
会注意到它或损坏其中一个文件?



可以改进以适应,或者我将不得不改变为新的散列算法?



(请不要通过讨论这个问题的可能性来避免这个问题 - 谢谢)

解决方案

如果两个文件在git中具有相同的哈希总和,它会将这些文件视为相同。在这种情况绝不可能发生的情况下,你总是可以返回一次提交,并修改文件中的某些内容,这样它们就不会再发生碰撞了......



请参阅 Linus Torvalds在帖子中的帖子开始考虑sha-256?在git邮件列表中。


What would actually happen if I had a hash collision while using git?

E.g. I manage to commit two files with the same sha1 checksum, would git notice it or corrupt one of the files?

Could git be improved to live with that, or would I have to change to a new hash algorithm?

(Please do not deflect this question by discussing how unlikely that is - Thanks)

解决方案

If two files have the same hash sum in git, it would treat those files as identical. In the absolutely unlikely case this happens, you could always go back one commit, and change something in the file so they wouldn't collide anymore ...

See Linus Torvalds' post in the thread "Starting to think about sha-256?" in the git mailing list.

这篇关于git中的哈希碰撞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆