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!
Wrong! In the commit logs, Git displays the timestamp in the format localtime + timezone offset. When reading the timestamps it’s important to take the timezone offset into account. Using the timezone offset you can convert the timestamp of the Commit 2 and Commit 3 into the UTC time in order to compare them.
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. As you can see, this command lists each commit with its SHA-1 checksum, the author’s name and email, the date written, and the commit message.
We can use git log command in order to list, filter, view commit history in different ways. In this tutorial we will examine git log command usage in detail with examples. We will start with git log command without any parameter. This will list all commit history in a interactive terminal where we can see and navigate.
And, if you just want to view the changes of a single commit from the log, you can copy the hash and run git show: Just having a list of commits can be messy to sort out branches. Luckily git log provides the --graph option which can be used alongside some
I was pretty sure it was possible using only git commands but I cannot find it now. --author-date-order
does not work for me on rebased branch, as suggested in another answer.
So one way to do that would be to use git log pretty=format: ...
to print the commit date in ISO format and let sort
or sort -r
fix the order.
For example:
git log --pretty=format:"%ad %h by %an, %s" --date=iso | sort -r | less
This will print the ISO date, the hash, the author and the message of the commit and sort it with the latest commits first.
You will find more format options at the PRETTY FORMATS section of git log --help
if you need more information per commit.
git log --author-date-order
This command sorts by author's timestamp instead of commit's timestamp
--author-date-order
Show no parents before all of its children are shown, but otherwise show commits in the author timestamp order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With