Git Introduction

2 minute read Published: 2020-04-29

Git is a “content tracker” – it records how files change over time. Think of it as a detailed history of your project, noting when, where, and by whom changes were made. This enables key features like:

Git’s underlying structure is a Directed Acyclic Graph (DAG) of Hashes. Each “hash” represents a specific version (or “commit”) of your content.

Understanding the Directed Acyclic Graph (DAG)

A DAG shows the relationships between different versions of your content. It’s like a family tree for your files:

+-------+       +-------+       +-------+
| grand |------>|parent |------>| child |
| parent|       |       |       |       |
+-------+       +-------+       +-------+

Hashes and Cryptographic Security

The DAG is built using “hashes”. A hash function takes any size input and produces a fixed-size output. In Git, each piece of content is hashed, creating a unique fingerprint. Cryptographic hashes, like SHA-1 (used in older versions) and SHA-256, are particularly important because they are designed to be extremely difficult to reverse – meaning you can’t figure out the original content just from its hash.

Commits: Snapshots of Content

A “commit” is a snapshot of your content at a specific point in time. Even though Git tracks changes at a file level, the commit itself records all the details of those alterations. We’ll delve deeper into commits in the next section.

Resources

  1. Git: Stupid Content Tracker.
  2. Tech Talk: Linus Torvalds on git
  3. wiki: Directed acyclic graph
  4. Hash Function Transition