Skip to content

Commit 6405036

Browse files
authored
Merge pull request #97 from braboj/fix/headings-readability
Improve heading structure and readability
2 parents bff12ff + da2ba01 commit 6405036

24 files changed

Lines changed: 373 additions & 217 deletions
39.1 KB
Loading

assets/drawio/git-object-model.drawio

Lines changed: 85 additions & 68 deletions
Large diffs are not rendered by default.

assets/images/git-object-model.png

-17.1 KB
Loading

astro-site/src/content/docs/appendix.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ section: "appendix"
44
order: 8
55
---
66

7-
## Overview
7+
## 1. Overview
88

99
This appendix contains reference material that supports the tutorial
1010
chapters — merge strategies, Git clients, external resources, and
1111
notes. For step-by-step recipes, see the [Playbook](../playbook/).
1212
For command help, run `git help <command>`.
1313

14-
## Merge Strategies
14+
In this chapter you will learn:
15+
16+
- Merge strategies — when Git uses each strategy and how to force one
17+
- SSH key setup — generate keys, configure the agent, and connect to GitHub
18+
- Git clients — popular graphical tools for each platform
19+
- References — books, troubleshooting guides, visualizations, and workflow models
20+
21+
## 2. Merge Strategies
1522

1623
Git selects a merge strategy automatically. You can force one with
1724
`git merge -s <strategy>`.
@@ -29,7 +36,7 @@ Git selects a merge strategy automatically. You can force one with
2936
> The option resolves individual conflicts by preferring the current
3037
> branch but still includes non-conflicting changes.
3138
32-
## SSH Key Setup
39+
## 3. SSH Key Setup
3340

3441
SSH lets you authenticate with remotes without entering a password
3542
each time. This is the recommended method for frequent use.
@@ -76,7 +83,7 @@ Hi username! You've successfully authenticated...
7683
$ git remote set-url origin git@github.com:user/repo.git
7784
```
7885

79-
## Git Clients
86+
## 4. Git Clients
8087

8188
| Client | Platform | Notes |
8289
|--------|----------|-------|
@@ -86,7 +93,7 @@ $ git remote set-url origin git@github.com:user/repo.git
8693
| [TortoiseGit](https://tortoisegit.org/) | Windows | Shell integration |
8794
| [Git Extensions](https://gitextensions.github.io/) | Windows | Lightweight, open source |
8895

89-
## References
96+
## 5. References
9097

9198
### Books and tutorials
9299

@@ -111,7 +118,7 @@ $ git remote set-url origin git@github.com:user/repo.git
111118
- [Trunk-Based Development](https://www.toptal.com/software/trunk-based-development-git-flow) — comparison with Git Flow
112119
- [OneFlow](https://www.endoflineblog.com/oneflow-a-git-branching-model-and-workflow) — simplified alternative to Git Flow
113120

114-
## Notes
121+
## 6. Notes
115122

116123
1. Git cannot commit empty folders. Add a placeholder file (e.g.
117124
`.gitkeep`) if you need an empty directory tracked.

astro-site/src/content/docs/branching-and-merging.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@ section: "branching-and-merging"
44
order: 3
55
---
66

7-
## Overview
7+
## 1. Overview
88

99
This chapter covers the daily workflow of parallel development in Git —
1010
creating branches, combining work through merging and rebasing,
1111
resolving conflicts, and temporarily shelving changes with the stash.
1212
These are the operations you will use most often when working with others
1313
or managing multiple features at once.
1414

15-
## Branching
15+
In this chapter you will learn:
16+
17+
- How to create, rename, and delete branches
18+
- Merge strategies: fast-forward, 3-way, no-fast-forward, and squash
19+
- How rebasing produces a linear history
20+
- How to cherry-pick individual commits between branches
21+
- How to resolve merge and rebase conflicts
22+
- How to stash and restore work in progress
23+
24+
## 2. Branching
1625

1726
As covered in [Building Blocks](../building-blocks/), a branch is a
1827
pointer to a specific commit. Creating a branch is a "cheap" operation —
@@ -98,7 +107,7 @@ To rename a different branch:
98107
git branch -m <oldName> <newName>
99108
```
100109

101-
## Merging
110+
## 3. Merging
102111

103112
Merging is a process of combining changes from different branches. Usually
104113
this is required when people are working in parallel on the same source code.
@@ -165,7 +174,7 @@ afterward.
165174
Squash merges are useful when a feature branch contains many small or
166175
messy commits and you want a clean, single-commit result on `main`.
167176

168-
## Rebasing
177+
## 4. Rebasing
169178

170179
Rebasing is an **alternative to merging**. Instead of creating a merge
171180
commit, it replays your branch's commits on top of another branch,
@@ -195,7 +204,7 @@ The table below summarizes when to use each approach:
195204
| Safe on shared branches? | Yes | No — rewrites commit hashes |
196205
| When to use | Combining finished work | Cleaning up local history before merging |
197206

198-
## Cherry-picking
207+
## 5. Cherry-picking
199208

200209
Cherry-picking copies a single commit from one branch onto another. Unlike
201210
merging, it does not bring over the full branch history — only the changes
@@ -223,7 +232,7 @@ Common use cases:
223232
> later merged, Git usually handles this cleanly, but it can produce
224233
> confusing history. Prefer merging when possible.
225234
226-
## Conflicts
235+
## 6. Conflicts
227236

228237
A merge conflict occurs when Git cannot automatically combine changes from
229238
two branches. This happens when both branches modify the same lines in the
@@ -404,7 +413,7 @@ git commit -m "Merge main into feature, combine greeting changes"
404413

405414
The conflict is resolved and the repository history records the merge.
406415

407-
## Stashing
416+
## 7. Stashing
408417

409418
The stash allows changes to be saved without committing broken or untested
410419
code before switching to another branch.

astro-site/src/content/docs/building-blocks.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ section: "building-blocks"
44
order: 2
55
---
66

7-
## Overview
7+
## 1. Overview
88

99
This chapter covers the internal building blocks of Git — how repositories
1010
are structured, how Git stores data as objects, and how references connect
1111
everything together. Understanding these internals will help you make sense
1212
of what Git commands actually do under the hood.
1313

14-
## Repository
14+
In this chapter you will learn:
15+
16+
- The difference between bare and non-bare repositories
17+
- How Git's object model stores files, directories, commits, and tags
18+
- How the index (staging area) prepares changes for commits
19+
- How references and HEAD connect names to commits
20+
- How to navigate and rewrite history with reset
21+
22+
## 2. Repository
1523

1624
A repository is a database that stores the complete history of a project
1725
as a series of snapshots (commits). Every commit records exactly what
@@ -83,7 +91,7 @@ The `.git` folder contains the same structure as a bare repository.
8391
The difference is that a non-bare repository also has a working tree
8492
next to it — the place where you do your actual work.
8593

86-
## Object Model
94+
## 3. Object Model
8795

8896
Every time you commit, Git takes a **snapshot** — a complete picture of
8997
every tracked file in your project at that moment. A snapshot is not a
@@ -318,7 +326,7 @@ Add project documentation
318326
| `-s` | Object size in bytes | `231` |
319327
| `-p` | Object content (pretty-print) | Depends on the type — see examples above |
320328

321-
## Index (Staging Area)
329+
## 4. Index (Staging Area)
322330

323331
The index is the area between your working tree and the repository. It
324332
holds a list of changes that are ready to be included in the next
@@ -388,7 +396,7 @@ and execute (1).
388396
So `100644` means "regular file, readable and writable by the owner"
389397
and `100755` means "executable file, runnable by anyone."
390398

391-
## References
399+
## 5. References
392400

393401
Every object in Git is identified by a 40-character hash, but humans
394402
don't think in hashes — we think in names like `main`, `feature/login`,
@@ -478,7 +486,7 @@ $ cat .git/refs/remotes/origin/main
478486
If this hash matches your local `refs/heads/main`, the branches are in
479487
sync. If they differ, one side has commits the other doesn't.
480488

481-
## History Navigation
489+
## 6. History Navigation
482490

483491
Navigating history in Git means moving two things: **HEAD** (your
484492
current position) and **branch tips** (where each branch points).

astro-site/src/content/docs/expert-topics.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@ section: "expert-topics"
44
order: 6
55
---
66

7-
## Overview
7+
## 1. Overview
88

99
This chapter covers power-user topics — configuration layers, revision
1010
selectors, pathspec and refspec syntax, interactive rebase, bisect,
1111
hooks, and garbage collection. These concepts are not needed for daily
1212
Git use but become essential as projects and teams grow.
1313

14-
## Configuration
14+
In this chapter you will learn:
15+
16+
- How Git's layered configuration system works and how to customize it
17+
- How to use revision selectors (tilde, caret, ranges) to navigate commit history
18+
- How pathspec patterns filter files in Git commands
19+
- How refspec syntax maps local and remote references
20+
- How to rewrite commit history with interactive rebase
21+
- How to find the commit that introduced a bug using bisect
22+
- How to automate tasks with Git hooks
23+
- How garbage collection and the reflog protect and clean up orphaned commits
24+
25+
## 2. Configuration
1526

1627
![Configuration Model](../assets/images/git-configuration-model.png)
1728

@@ -69,7 +80,7 @@ $ git config --list --show-scope # all settings with scope level
6980
When the same parameter is set at multiple levels, the most specific
7081
wins: local overrides global, global overrides system.
7182

72-
## Revision Selectors
83+
## 3. Revision Selectors
7384

7485
Revision selectors let you reference specific commits without knowing
7586
their hashes. They are used with `git log`, `git diff`, `git show`,
@@ -137,7 +148,7 @@ $ git show "HEAD@{yesterday}" # where HEAD was yesterday
137148
$ git show "main@{2.weeks.ago}" # where main was 2 weeks ago
138149
```
139150

140-
## Pathspec
151+
## 4. Pathspec
141152

142153
A pathspec is a pattern that matches files or directories. Most Git
143154
commands that work with files accept pathspecs.
@@ -175,7 +186,7 @@ Signatures control the matching behavior. Syntax: `:(signature)pattern`
175186

176187
Signatures can be combined: `':(top,icase)*.mp?'`
177188

178-
## Refspec
189+
## 5. Refspec
179190

180191
When you run `git fetch` or `git push`, Git needs to know which
181192
references on one side map to which references on the other. A refspec
@@ -216,7 +227,7 @@ $ git push origin :refs/heads/feature # delete remote branch (empty src)
216227
$ git fetch origin main:refs/remotes/origin/main # fetch one branch explicitly
217228
```
218229

219-
## Interactive Rebase
230+
## 6. Interactive Rebase
220231

221232
Interactive rebase lets you edit, reorder, squash, or drop commits
222233
before sharing them. It rewrites history — use it only on local
@@ -261,7 +272,7 @@ Result: one commit with a combined message replacing all three.
261272
> **Warning:** Interactive rebase rewrites commit hashes. Never rebase
262273
> commits that have already been pushed to a shared branch.
263274
264-
## Git Bisect
275+
## 7. Git Bisect
265276

266277
`git bisect` performs a binary search through commit history to find
267278
the commit that introduced a bug. Instead of checking every commit,
@@ -299,7 +310,7 @@ $ git bisect run ./test.sh
299310
Git runs the script at each midpoint automatically and reports the
300311
first bad commit when done.
301312

302-
## Hooks
313+
## 8. Hooks
303314

304315
Hooks are scripts that Git runs automatically before or after specific
305316
events. They live in `.git/hooks/` and are not tracked by Git (each
@@ -352,7 +363,7 @@ $ git push --no-verify # skip pre-push hook
352363

353364
Use sparingly — hooks exist for a reason.
354365

355-
## Garbage Collection
366+
## 9. Garbage Collection
356367

357368
When you reset, rebase, or delete a branch, the commits that were on it
358369
don't disappear immediately. They become **orphaned** — they still exist

astro-site/src/content/docs/glossary.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ order: 9
66

77
## Glossary
88

9+
A reference of key Git terms used throughout this tutorial, with links to the chapter where each concept is covered.
10+
911
| Term | Definition | Chapter |
1012
|------|-----------|---------|
1113
| Annotated tag | A tag object with author, date, and message — stored in `.git/objects/` | [2](../building-blocks/) |

astro-site/src/content/docs/introduction.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ section: "introduction"
44
order: 1
55
---
66

7-
## Overview
7+
## 1. Overview
88

99
Git is a version control system. It keeps a complete history of every change
1010
you make to your files, so you can go back to any earlier version at any time.
@@ -18,7 +18,15 @@ Why use version control?
1818
- Multiple people can work on the same project without overwriting each other
1919
- You can experiment on a separate branch and merge it back when it works
2020

21-
## Features
21+
In this chapter you will learn:
22+
23+
- What Git is and why version control matters
24+
- How to install Git on your platform
25+
- Where to host your repositories
26+
- How Git moves changes through workspace, index, and repository
27+
- The most common commands in daily operations
28+
29+
## 2. Features
2230

2331
Git is **open source** and free to use. Unlike older systems such as
2432
Subversion (SVN) where all history lives on a central server, Git is
@@ -31,34 +39,26 @@ share with others when you are ready.
3139
- **Branching** — work on separate ideas at the same time without interfering with each other
3240
- **Fast** — most operations happen on your own machine, with no waiting for a server
3341

34-
## Installation
35-
36-
Download Git from the official website: https://git-scm.com/downloads
37-
38-
After installation, open a terminal and verify with:
39-
40-
```text
41-
$ git --version
42-
```
42+
## 3. Installation
4343

4444
### Windows
4545

46-
1. Download the installer from the link above
46+
1. Download the installer from https://git-scm.com/downloads
4747
2. Run the installer with the default options
48-
3. Open PowerShell and verify
48+
3. Open PowerShell and run `git --version`
4949

5050
### macOS
5151

5252
**Option A — Xcode Command Line Tools (no extra software needed):**
5353

54-
1. Open Terminal and type `git --version`
54+
1. Open Terminal and run `git --version`
5555
2. If Git is not installed, macOS will prompt you to install the Command Line Tools — follow the dialog
5656

5757
**Option B — Homebrew:**
5858

59-
```text
60-
$ brew install git
61-
```
59+
1. Install [Homebrew](https://brew.sh/) if you do not have it
60+
2. Run `brew install git`
61+
3. Run `git --version`
6262

6363
### Linux
6464

@@ -73,7 +73,9 @@ $ brew install git
7373
| FreeBSD | `pkg install git` |
7474
| Nix/NixOS | `nix-env -i git` |
7575

76-
## Hosting
76+
After installing, run `git --version` to verify.
77+
78+
## 4. Hosting
7779

7880
A Git hosting service stores your repositories online so you can access them
7981
from anywhere and collaborate with others. You do not need your own server —
@@ -93,7 +95,7 @@ The table below compares the free tiers of each provider.
9395

9496
![Git Hosting Comparison](../assets/images/git-hosting.png)
9597

96-
## How Git Works
98+
## 5. How Git Works
9799

98100
Git moves your changes through three locations before they are shared
99101
with others. The diagram below shows these locations and the commands
@@ -124,7 +126,7 @@ both as equals — there is no single authoritative copy. (The word "master"
124126
here means primary, not the branch name `master` — Git uses `main` as the
125127
default branch name.)
126128

127-
### How a commit works
129+
### How a Commit Works
128130

129131
When you run `git commit`, Git takes a snapshot of everything in the index
130132
and stores it permanently in the repository. Each snapshot is called a
@@ -147,7 +149,7 @@ In the diagram above, `D` is the latest commit. It points back to `C`,
147149
which points to `B`, and so on. Git follows these links to reconstruct the
148150
full history.
149151

150-
## Command Overview
152+
## 6. Command Overview
151153

152154
![Command Overview](../assets/images/git-command-overview.png)
153155

0 commit comments

Comments
 (0)