# Git Anatomy

How Git saves snapshots with commit, splits work onto branches and joins them back with merge, shown along a visible history line\.

By Numa

Topic: Computing, AI &amp; Electronics

[Open the interactive Jig](https://ask.jig.com/j/Qo7Jtrmus9H4)

## Transcript

### 1. Git Anatomy

Git is a tool that remembers every saved version of a project, like a photo album for your files\. This little machine shows its three big moves: commit saves a snapshot, branch starts a side path, and merge joins paths back together\. Follow the glowing line along the back: it is your project's history\.

Linus Torvalds wrote the first version of Git in April 2005 to look after the Linux kernel\.

### 2. The working directory

The desk on the left is your working directory: the ordinary files you open and change\. Watch the middle card: you have just added a new line to it\. Git notices the change, but nothing is saved yet\.

### 3. Staging with git add

The tray is the staging area, where you gather changes for your next snapshot\. Running git add puts a copy of the changed file there\. Git also seals the file's contents into the vault on the right\.

Press the button, or click the middle card on the desk\.

### 4. Saving a snapshot with git commit

A commit is a saved snapshot of the whole project, including the changes waiting in the tray, plus a short message about what changed\. Press git commit: the staged card rises from the tray and becomes a new block on the glowing history line\. The branch flag called main moves onto it\. HEAD, the black\-edged marker, means 'you are here'\.

Each commit gets a 40\-character ID calculated from its contents, so we usually show only the first 7\.

### 5. A chain of snapshots

Each commit points back to the one before it, called its parent\. Watch the light flow along the line from the oldest commit to the newest\. Change anything in an old commit and its ID changes, so every later link breaks\. That is how Git keeps history honest\.

Drag empty space to turn the machine and look at it from any side\.

### 6. Branches are tiny pointers

A branch is a separate path of work, so you can try an idea without disturbing main\. It is not a copy of your files, just a name that points at one commit\. Press git branch: a new flag appears and HEAD hops onto it\.

A branch is stored as a tiny file of just 41 bytes\.

### 7. Working on a branch

With HEAD on the new branch, your next commit goes there\. Watch the glowing line split: the new commit rises onto its own pink lane, and the branch flag climbs with it\. Main stays exactly where it was, so the original work is safe\.

### 8. Joining up with git merge

When the idea works, you bring it back\. Press git merge: HEAD returns to main, and Git makes a merge commit with two parents, one from each path\. The pink and blue lines flow into one, and main moves forward\.

Main had not moved here, so plain git merge would just slide the flag forward
