Logs / The git log

git log --since=1.week

Basic usage

Using the git log we can see streams of commits that have happened in the repo.

Run this in our workshop git repo

git log --author Vonnie

We see a chronological order of commit messages and references, along with the author name and time - neat.

Log between two refs

The most common usage, is to see the changes that took place between two known points

git log release..develop

Use HEAD~3 to point to 3 commits behind HEAD. git log assumes HEAD if a range point isn’t given.

git log HEAD~3..

Or use ^ as a shortcut for the ‘one commit back’

git log HEAD^..

Search by author

To search the log by author, just give part of their name as a parameter

git log --author Vonnie

Search during a time period

Fairly easy to search during a human time period

git log --after="Dec 2018" --before="Feb 2019"

Search using grep

We can search commit message using grep - something that’s actually quite difficult in Github/Bitbucket

git log --grep 'rubocop'

Log traversal

So we can generate a log that goes back 3 commits from HEAD like this:

git log -n 3

Full patch details

We can retrieve back the changes that a commit made by adding the -p parameter.

So this would get back the last change

git log --oneline -p -n 1


Let’s take a look at shortlog for git generated changelogs