Reputation: 3755
When I run git log --oneline
for example, it outputs a list of commits in chronologic order (descendent). My question is: What criteria git uses to sort this list? Does it use the author_date
or the committer_date
to order the result? Or it uses another? This can be an issue for me if it sort by committer_date
as this attribute can change over time. I appreciate any help about this.
Upvotes: 2
Views: 786
Reputation: 75926
Actually the primary sort criterion is given by the parent-child relationships, which are always respected in log listings (if three commits are chained A->B->C
they will never be displayed in A C B
order, no matter the dates or the log options).
But when we are displaying commits from paralell branches, there is some freedom in the ordering.
For this scenario, there exist the options --date-order --topo-order
. And here, "date-order" (the default) means the committer_date
. If you wish to sort by the author date, there is the additional option --author-date-order
.
If you are listing commits from a single branch, then these options are irrelevant.
Doc: https://git-scm.com/docs/git-log#_commit_ordering
---1----2----4----7
\ \
3----5----6----8----9--
Suppose you have this commit history (copied from docs) where the horizontal coordinate corresponds to the (author) date. Then the log list will display:
date-order topo-order topo-order (alt)
9 9 9
8 8 8
7 6 7
6 5 4
4 3 2
5 7 6
2 4 5
3 2 3
1 1 1
More info here
Upvotes: 4