snippetjavascriptTip
View a short summary of Git commits
Viewed 0 times
shortsummaryviewgitcommits
Problem
One of the most common things you might need to do when working with Git is to view a short summary of your commits. While
One of these is
Notice the short, 7-character commit identifiers. This is because of the
Other options can be used in conjunction with
git log is the go-to command for this, it can be a bit verbose at times. Luckily, it provides a plethora of options to help you customize its output.One of these is
--oneline, which is actually a shorthand for --pretty=oneline --abbrev-commit. It prints a short summary of all commits, with each commit being printed on a single line.Notice the short, 7-character commit identifiers. This is because of the
--abbrev-commit option, which abbreviates the commit SHA-1 checksum to 7 characters. This shorter string is enough to uniquely identify a commit.Other options can be used in conjunction with
--oneline to further customize the output. For example, you can use --no-merges to exclude merge commits from the output.Solution
git log --oneline
# d540ba1 Merge network bug fix
# 3050fc0 Fix network bug
# c191f90 Initial commitNotice the short, 7-character commit identifiers. This is because of the
--abbrev-commit option, which abbreviates the commit SHA-1 checksum to 7 characters. This shorter string is enough to uniquely identify a commit.Other options can be used in conjunction with
--oneline to further customize the output. For example, you can use --no-merges to exclude merge commits from the output.Code Snippets
git log --oneline
# d540ba1 Merge network bug fix
# 3050fc0 Fix network bug
# c191f90 Initial commitgit log --oneline --no-merges
# 3050fc0 Fix network bug
# c191f90 Initial commitContext
From 30-seconds-of-code: view-commits-summary
Revisions (0)
No revisions yet.