Can you order git log by commit timestamp?

Viewed 27121

So I recently rebased a branch and merged it into master. When I do git log, I get a pretty, linear history of commits. But I want to see my commit history based on timestamp so I can easily compare when the commits on two branches were made in realtime.

Is there a git log option that can order commits by timestamp instead of their normal commit history? I can't seem to find one. Thanks!

3 Answers

Things might have changed since the question was asked, but in the current git 2.35 there are three different orderings for logs. From the git log help page:

  • --date-order: Show no parents before all of its children are shown, but otherwise show commits in the commit timestamp order.
  • --author-date-order: Show no parents before all of its children are shown, but otherwise show commits in the author timestamp order.
  • --topo-order: Show no parents before all of its children are shown, and avoid showing commits on multiple lines of history intermixed.

The default is --date-order, although --graph implies --topo-order.

With rebased branches, --date-order will sort by when the commits were rebased, while --author-date-order will sort by when they were originally committed.

(Keep in mind though that there are various ways to mess about with timestamps, so they're not entirely reliable.)

Related