Read history after a merge

Lesson 14 of 25 · Git: records, branches, and collaboration

A history graph shows relationships; it does not by itself show whether the combined files are correct. To inspect all referenced histories in the local repository:

git log --oneline --graph --decorate --parents --all

Each * marks a commit. The first abbreviated ID on a row identifies that commit; with --parents, subsequent IDs identify its parent or parents. Connecting lines depict ancestry. Decorations include branch names and often HEAD -> main. Hashes, row order and graph layout vary. --all includes histories reachable from references, not necessarily unreachable commits.

For a merge commit currently checked out, this narrower view prints its own ID, its parent IDs and its subject:

git show --no-patch --format='%h %p %s' HEAD

A normal merge commit has two parents; a root commit has none. To inspect the resulting content, use git show or compare relevant commits with git diff <older-id> <newer-id> after replacing the placeholders with actual IDs. A diff describes content differences; the graph explains ancestry.

Rebase is another way to integrate work: it replays eligible commits onto a new base, usually making new commit IDs instead of joining existing histories. Do not casually rebase commits others depend on; coordinate history rewrites. This chapter uses merge, leaving a detailed rebase workflow for later material.