Commit log

The log shows the history of the commit snapshots.

There are several log options. The default one isn’t such useful actually.

I usually view my log with the following options.

$ git log --oneline --graph --decorate --color --all

It’s a very long command, right? So I usually set it as an alias command. This can be done by setting the alias in the .gitconfig file.

[alias]
    lg = log --all --oneline --graph --decorate --color

NOTE: The .gitconfig file is usually in the home directory.

Explaining

So what does those options mean?

  • The --oneline shows the simplified version.
  • The --graph shows the commit relationship path on the left. So that the sequence of log becomes a commit path.
  • The --all shows all branches, including the remote branch. Otherwise, git log only shows the current branch.
  • The --decorate shows the branch pointers to the commits.
  • The --color, as the name suggests, makes the log output colorful and easier to read.