git-log is a command-line utility in the Git version control system used to display commit logs. It provides an extensive history of changes made to a project, allowing developers to track modifications, understand the evolution of the codebase, and investigate issues or contributions over time.
Git, along with git-log, was created by Linus Torvalds in 2005 for the development of the Linux kernel. Initially, Git was designed with simplicity and speed in mind, which influenced the development of its logging tools. The git-log command has evolved to include numerous options for filtering, formatting, and sorting the commit history, making it a versatile tool for developers.
The git-log command offers various options to customize the output:
git log
shows the commit history for the current branch, with each commit listed in reverse chronological order by default.--pretty=oneline
, --graph
, or --format
to visualize the commit history in different ways.--author
, --grep
, or --since
allow filtering commits by author, commit message, or date range.-n
or --max-count
, users can limit the number of commits shown, while -p
or --patch
shows the actual changes introduced by commits.-U
to control the context lines shown.--date-order
, --author-date-order
, or --topo-order
.
git log --oneline --graph --all
git log --author="John Doe" --since="1 week ago"
git log --pretty=format:"%h - %an, %ar : %s"
git-log is indispensable for: