• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

“git log” Command Examples

by admin

In Git, “git log” is a command that allows you to view the history of commits in a repository. It displays a list of commits, starting from the most recent one and going back in chronological order.

When you run the “git log” command in your terminal or command prompt within a Git repository, you’ll see a detailed output that provides information about each commit. The information typically includes:

  • Commit Hash: A unique identifier for each commit. It’s a long string of characters that helps you reference the commit in various Git operations.
  • Author and Date: The name and email address of the person who made the commit, along with the date and time the commit was created.
  • Commit Message: A short description provided by the author that summarizes the changes made in the commit. This message helps you understand the purpose of the commit.

By default, “git log” displays the commit history in a text-based format, but you can also customize the output using various command-line options. For example, you can specify the number of commits to show, filter the commits based on specific criteria, or format the output to include additional information.

The commit history displayed by “git log” is essential for understanding the evolution of a Git repository. It helps you track changes, identify who made specific modifications, and review the progression of the project over time. Additionally, the commit hash provided in the log allows you to reference specific commits when performing operations like reverting changes, creating branches, or merging code.

git log Command Examples

1. Show the sequence of commits starting from the current one, in reverse chronological order of the Git repository in the current working directory:

# git log

2. Show the history of a particular file or directory, including differences:

# git log -p /path/to/file_or_directory

3. Show an overview of which file(s) changed in each commit:

# git log --stat

4. Show a graph of commits in the current branch using only the first line of each commit message:

# git log --oneline --graph

5. Show a graph of all commits, tags and branches in the entire repo:

# git log --oneline --decorate --all --graph

6. Show only commits whose messages include a given string (case-insensitively):

# git log -i --grep search_string

7. Show the last N commits from a certain author:

# git log -n number --author=author

8. Show commits between two dates (yyyy-mm-dd):

# git log --before="2017-01-29" --after="2017-01-17"

Summary

Overall, “git log” is a powerful command that provides a detailed view of the commit history in a Git repository, enabling you to navigate and analyze the changes made to the project.

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to uninstall lammps package from Ubuntu
  2. env Command Examples in Linux
  3. CentOS / RHEL 7 : How to install and configure ftp server (vsftpd)
  4. aws glue – CLI for AWS Glue (Command Examples)
  5. “You must wait longer to change your password” – error while changing password in CentOS/RHEL
  6. fping: A more powerful ping which can ping multiple hosts
  7. lastlog: command not found
  8. lrztar: command not found
  9. snap: command not found
  10. “aws s3api” Command Examples

You May Also Like

Primary Sidebar

Recent Posts

  • gml2gv Command Examples
  • glow Command Examples
  • glib-compile-resources Command Examples
  • glances Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright