Skip to content

Git History and Search

Kenneth Kasajian edited this page Feb 17, 2021 · 2 revisions
List commits made in the repository
 git log

Mode condensed:

 git log --pretty=oneline

With abbreviated status:

 git log --stat

Use -p to show diff introduced in each commit, and -2 to limit output to last 2 entries:

 git log -p -2

Custom format:

 git log --pretty=format:"%h - %an, %ar : %s"

Last 5 commits:

 git log --oneline HEAD~5..HEAD

Common commands:

git log --graph --oneline --decorate --date-order

git log --graph --oneline --decorate --date-order --no-merges 

Searching:

Find a commit by commit message:

git log -p --grep "nasty bug"

Or

git show :/'nasty bug'

Show commits that contain the provided string in the commit content itself.

git log -p -S 'Date.new'

Through all branches:

git log -S 'populate_database' --all

Show by author:

git log --author=<partial_name_of_user>

Specify date-range:

git log --since=2014-09-03 --until=2014-12-31

New commits between wip and master:

git log wip..master --oneline

More:

http://www.held.org.il/blog/2013/03/navigating-through-the-git-history-like-a-boss/


References