Five git log oneline examples
The default git log command doesn’t provide the most visually pleasing results. The output is bulky and can make inspecting the commit history cumbersome. The solution? Use the –pretty=oneline switch whenever you need to view the git log.
The oneline switch is the default for the reflog command, so it should feel familiar:
git log --pretty=oneline
You can actually don’t need to prepend -pretty to the oneline switch, as there’s a built in alias for the command:
git log --oneline
Visualize branches with git log graph
A nice addition to the oneline switch is the –graph option. This creates a visual depiction of branch creation, checkouts and merges.
git log --oneline --graph
To include extra data about all branches, commits and authors in the graph you can add the decorate and all switches:
git log –all –decorate –oneline –graph
All of the features of the pretty switch are available to the git log command when online is used, so if you really want to get crazy, you can include a variety of customization to the rendering of the log as well:
git log --graph --pretty="%C(yellow) Hash: %h %C(blue)Date: %ad %C(red) Message: %s " --date=human
The git log is the window into your organization’s workflow and development history. Being able to format the output with git log –oneline switch will help save you time when the need arises to inspect your Git commit history.