Menu

What is the function of git log?

  • Git Log is used for Formatting the log output, Summary or history or filtering the commit.
  • Git log figures out where the bugs are introduced, to see the project history, revert problematic changes.
  • But the basic git log function is to show the commits.
  • You can alter the function of the git log bypassing many parameters into it.
  • By git log, you can filter commit history. 

Limit number of commits displayed

  • The most basic filtering option for git log is to limit the number of commits that are displayed.
  • git log -<n> // <n> => You can limit git log output
  • git log -3 // Display recent 3 commits

Filter by date

  • git log //Function can also filter by date
  • git log --after="2014-7-1"
  • git log --after="yesterday"    

Filter by the name of the author

  • git log --author="John"

Filter either by Ashok/Mathew

  • git log --author="John|Mathew"

Filter by message

  • git log --grep="Rest"

Filter By File

  • git log -- test.php index.php
  • //It returns all the commits that affected either by test.php or index.php

Filter By Content

  • git log -S"Hello, World!"
  • //It is possible for a search for commits that remove or introduce