git log is an excellent command to view the history of commits in your project. There are a number of flags it can take to customize the output. These are some of my favorites.

git log

Returns the entire history of the current branch of your project


git log --oneline

Condensed view of git log. Displays only a truncated commit hash and the commit message.


git log -4

Shows just the last 4 commits


git log -name-status

Shows the files that were changed in each commit


git log -p

Shows the file diff in the log output


git log --after="2019-07-01" --before="2019-09-30"

Shows commits in a date range


git log --grep="mesa verde"

Shows commits where commit message contains a term


git log -- config.py

Shows commits just for a given file


git log -S"heisenberg"

# OR 

git log -G"\bh[a-z]*rg\b"

Shows commits where that term was added to a file. -S flag for text search; -G for regex search


Published

Category

Programming

Tags

Contact