git log <commitA>..<commitB>

Show the commits that are reachable from the second commit but not from the first.

This command is useful for comparing two points in history by listing only the commits that are included in one commit (or branch) but not in another, helping you understand what changed between them.

This command shows the commit history that is reachable from <commitB> but not from <commitA>, where the ..<..> range syntax means "all commits in the right side that are not in the left side"; you can use any valid commit-ish for <commitA> and <commitB>, such as branch names, tags, or commit hashes. Under the hood, Git treats <commitA>..<commitB> as shorthand for ^<commitA> <commitB>, effectively excluding all ancestors of <commitA> while including the history leading to <commitB>. You can customize the output with flags like --oneline (or -–pretty=oneline) to show each commit on a single line, --graph to add an ASCII graph of the branch structure, or --stat to show which files changed in each commit; these flags only change how the same commit set is displayed.

You can invert or broaden the comparison by using a different range syntax such as git log <commitA>...<commitB> (three dots) to show commits that are in either side but not in both (the symmetric difference), or by dropping the left side entirely (for example git log <commitB>) to see the full history of one side. Closely related commands include git diff <commitA>..<commitB> to see the actual content differences instead of just the commit list, and git log --left-right <commitA>...<commitB> to show which side each commit belongs to when using the symmetric range.

Examples:

  • git log main..feature/login-form
  • git log v1.0.0..v1.1.0 --oneline --graph
  • git log 1a2b3c4..5d6e7f8 --stat
Manual page
git log
Related commands

Welcome to GitExamples!

Sign in to gitexamples