提交ID来自何处? [英] Where do commit ids come from?

查看:37
本文介绍了提交ID来自何处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此真的很好奇.提交ID不能是随机的,因为它们必须是唯一的.但是,它们似乎是随机的,这让我感到奇怪,为什么它们不只是连续的数字?我的意思是,它们只需要在存储库中唯一,对吗?还是我错了?

I'm just really curious about this. Commit ids can't be randomised, since they need to be unique. They appear to be random, though, and it got me wondering, why aren't they just consecutive numbers? I mean, they only need to be unique within the repository, right? Or am I in the wrong here?

谢谢!

推荐答案

Git提交ID为SHA-1哈希

在像Git这样的分布式版本控制系统中,修订号必须在所有系统中保持一致.由于Git历史记录是有向无环图,而不是线性序列,因此提交和对象使用SHA-1散列进行系统间的明确标识.

Git Commit IDs are SHA-1 Hashes

In a distributed version control system like Git, revision numbers must be consistent across all systems. Because Git history is a directed acyclic graph rather than a linear series, commits and objects use a SHA-1 hash for unambiguous identification across systems.

Commit ID在Git中不是随机的.它们实际上是提交对象的SHA-1哈希,其中包括树和对象的清单.有关其他详细信息,请参见 Git内部.最终结果是,任何给定的对象哈希都是确定性的:相同的对象将导致相同的哈希,而不管其如何到达当前状态.

Commit IDs aren't random in Git. They are in fact SHA-1 hashes of the commit object, which includes a manifest of trees and objects. See Git Internals for additional details. The end result is that any given object hash is deterministic: the same object will result in the same hash regardless of how it arrived in the current state.

这篇关于提交ID来自何处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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