The `--first-parent` option in `git log` restricts the log to only follow the first parent commit after a merge, effectively ignoring commits that came in via merged branches. This is useful when you want to replay the history of a branch as it appeared linearly, without re-processing commits introduced through feature branch merges. A concrete example illustrates how a naive `git log` can produce confusing duplicate change entries when merges are involved, and how `--first-parent` resolves this by showing only the merge commit rather than each individual commit from the merged branch.

3m read timeFrom marcgg.com
Post cover image
Table of contents
Example SystemThe ProblemThe Solution Using first-parent

Sort: