![]() |
Git is a powerful version control system that allows developers to manage changes to their codebase efficiently. One of Git’s most useful features is the Table of Content Basic Git Log UsageThe basic git log
While this output is informative, it can be difficult to scan quickly. Fortunately, Git provides several options to customize this output. Why Customize Git Log Output ?The default output of
Customization OptionsFormatting Commit OutputYou can format the output of
Limiting OutputLimiting the number of commits displayed can prevent information overload, especially in large repositories. git log -5 // Displays the last 5 commits
Filtering CommitsFiltering commits based on criteria such as author, date range, or specific paths can provide a focused view of relevant changes. git log --author="John Doe" --since="2022-01-01" -- path/to/file
Graphical RepresentationAdding a graphical representation (ASCII art) of commit history using git log --oneline --graph
Accessing Git LogStep 1: Open a terminal or command prompt. Navigate to the Git repository directory using the cd command. cd Name_of_Repository
Step 2: Then type git log and press enter to view the default log output. git log
The default log displays commits in reverse chronological order, showing commit hashes, authors, dates, and commit messages. ![]() git log Customizing Log OutputWe can customize the git log output by using different formatting options. Common formatting options include –oneline, –graph, –decorate, –stat, and –pretty.
–onelineIt can be used to display a concise, one-line summary of each commit. For example – git log --oneline
![]() Using –oneline option –graphDraws a text picture of the project’s history, showing branches and merges. For example – git log --graph
![]() Using –graph option –decorateShows the names of branches and tags next to each commit. For example – git log --decorate
![]() Using –decorate option –statIt can be used to get the number of insertions and deletions made in each commit. For example – git log --stat
![]() Using –stat option –pretty=format:”…”It lets you create a custom format for showing commits. This is the most customizable option. For example, the command below will display commits in a format like abbreviated-hash – author-name, date : commit-message. git log --pretty=format:"%h - %an, %ar : %s"
![]() Using –pretty option |
Reffered: https://www.geeksforgeeks.org
Git |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |