Govur University Logo
--> --> --> -->
...

How does Git use SHA-1 hashes to guarantee that no part of a project's history can be changed without detection?



Git uses SHA-1 (Secure Hash Algorithm 1) hashes as unique, fixed-size fingerprints for all pieces of data it stores, ensuring that any alteration to a project's history is immediately detectable. A SHA-1 hash is a 40-character hexadecimal string, mathematically derived from the exact content of the data. Its key properties are determinism—the same input always produces the same output—and collision resistance, meaning it's computationally infeasible to find two different inputs that produce the same hash, or to find an input that matches a given hash. Git stores three main types of objects, each identified by its content's SHA-1 hash: 1. Blob objects: These store the exact content of a file. If even a single byte within a file changes, its blob object's SHA-1 hash will be completely different. 2. Tree objects: These represent a directory snapshot. A tree object contains a list of entries, each pointing to a blob object (for a file) or another tree objec....

Log in to view the answer



Redundant Elements