Git ~ Log - rohit120582sharma/Documentation GitHub Wiki
The purpose of any version control system is to record changes to your code. This gives you the power to go back into your project history to see who contributed what, figure out where bugs were introduced, and revert problematic changes. But, having all of this history available is useless if you don’t know how to navigate it. That’s where the git log command comes in.
The advanced features of git log can be split into two categories: formatting how each commit is displayed, and filtering which commits are included in the output. Together, these two skills give you the power to go back into your project and find any information that you could possibly need.
The --oneline flag condenses each commit to a single line. By default, it displays only the commit ID and the first line of the commit message.
$ git log --oneline
Many times it’s useful to know which branch or tag each commit is associated with. The --decorate flag makes git log display all of the references (e.g., branches, tags, etc) that point to each commit.
$ git log --decorate
The git shortlog command groups each commit by author and displays the first line of each commit message. This is an easy way to see who’s been working on what.
$ git shortlog
The --graph option draws an ASCII graph representing the branch structure of the commit history. This is commonly used in conjunction with the --oneline and --decorate commands to make it easier to see which commit belongs to which branch:
$ git log --graph --oneline --decorate
When you’re only looking for commits created by a particular user, use the --author flag.
$ git log --author="John"
To filter commits by their commit message, use the --grep flag. It searches for commit messages that match a regular expression. You can also pass in the -i parameter to git log to make it ignore case differences while pattern matching.
$ git log --grep="JRA-224:" -i
You can prevent git log from displaying these merge commits by passing the --no-merges flag:
$ git log --no-merges
On the other hand, if you’re only interested in the merge commits, you can use the --merges flag:
$ git log --merges