Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make git log order based on author's timestamp?

I use a fairly complex git-log command involving --date-order to get an overview of my repository's status; but unfortunately, --date-order seems to use the committer date, not the author date. That means that each time I bring my topic branches up to date by rebasing them onto the current upstream, I lose the helpful chronological ordering in my git-log of relative commits in my topic branches (that is, each branch becomes a single long line, because all of its commits got rebased to sequential and nearly-identical committer timestamps.)

If I could get git-log to order commits by the author timestamp instead of the committer timestamp, this would be solved. Does anybody know of a way to do that?


For those visiting this from Google results, you may want to look into josephdpurcell's solution (and in-depth blog post!), below. It's quite excellent, if you're looking for standard git-log style output, multi-line, with detailed messages about each commit.

Unfortunate, I now need to amend this question, because I'm an idiot and didn't provide more specific information about my use-case: I use git-log in “--graph mode,” and I need to make git-log itself operate in author-date-order. As far as I've been able to ascertain, this is completely impossible to do from outside git-log, because git-log itself handles the graph ordering and printing.

A script, or patch for git-log, may be necessary, it seems. I'll leave this open until somebody can either 1. write such a script, or 2. we can talk the git authors into including a --author --date-order combination of flags. (=


For reference, here's what my current glog function's output looks like, and what I need to re-order:

glog output

like image 619
ELLIOTTCABLE Avatar asked Dec 20 '11 13:12

ELLIOTTCABLE


People also ask

Is git log in chronological order?

By default, with no arguments, git log lists the commits made in that repository in reverse chronological order; that is, the most recent commits show up first.

Which command is used to check last 5 commits by a particular author?

The git shortlog command is a special version of git log intended for creating release announcements. It groups each commit by author and displays the first line of each commit message.

What is author date in git?

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019 | TFS 2018. Git tracks two dates in commits: author date and commit date. In addition, Azure DevOps Services and TFS track when a commit was first pushed to the server. Author date: when a commit was originally authored.

Are git commits time stamped?

There are actually two different timestamps recorded by Git for each commit: the author date and the commit date. When the commit is created both the timestamps are set to the current time of the machine where the commit was made.


1 Answers

git version 1.8.4 added an --author-date-order argument to git log; according to the release notes, "the output is topologically sorted and commits in parallel histories are shown intermixed together based on the author timestamp."

like image 195
M Somerville Avatar answered Oct 13 '22 00:10

M Somerville