1. View Commit History
Command: Git log
2. Option--pretty[=<format>]
1) Introduction
In addition to the default format to view the commit history, you can also make the output format by--PRETTY[=<FORMAT>] or--format[=<format>] <format> can be a noeline, short, medium, full, fuller, email, raw, format: one of their respective output formats can refer to git log--help or (3). Next we mainly discuss format: how to use it.
2) Custom submission format--pretty=format:
--pretty=format: The use of "format" is just like printf's usage, except that the line break changes from \ n to%n. Here are some commonly used placeholders, from (1) and (2), and refer to (3) or git log--help for more details.
Option description
%H full hash string for commit object (commit)
%h a short hash string for the Commit object
Full hash string for%T tree object
Short hash string for%t tree object
The full hash string of the parent object (%P)
%p a short hash string for the parent object
The name of the%an author (author)
%_ae The author's e-mail address (please remove the _ in%_ae due to Sina blog display problem)
%_ad Author revision date (can be customized with the-date= option) (Please remove the _ in% ad due to Sina blog display problem)
%ar Author revision date, by how long before the way display
%CN the name of the submitter (committer)
%_ce The submitter's e-mail address (please remove the _ in%_ce due to Sina blog display problem)
%_CD Submission Date (Please remove the _ in%_cd due to Sina blog display problem)
%CR submission date, as of how long ago the way it appears
%d:ref Name
%s: Submitted information title
%b: Content of submitted information
%cred: Switch to Red
%cgreen: Switch to Green
%_cblue: Switch to Blue (due to Sina blog display problem, please remove the _ in%_cblue)
%creset: Reset Color
%c (...): Make color, as described in color.branch.* config option
%n: Line break
Note: What is the difference between the author (author) _ and _ Submitter (committer), in fact, the author refers to the person who actually made the change, the submitter refers to the person who finally submits the result of the work to the warehouse. So, when you post a patch for a project, and then a core member incorporates your patch into the project, you are the author, and that core member is the submitter. References from (1).
For example, we only need to output the completed hash value and the submitted information header, so we can use the command:
$git log--pretty=format: "%H%n%s"
38896a27dc8ab4f47883bd67d300f6145f0478b7
Commit Write 2
7d3e94cf22b17f7d097479ae8d9367e42509bb3f
Initial Commit
3) Customize the log format that belongs to you
According to the instructions above, we can customize our own log format:
$git config--global alias.lg "log--graph--pretty=format: '%cred%h%creset @%c (yellow)%d%creset%n Author:%CN <%_CE&G T %n Date:%_cd%_cblue (%CR)%creset%n%n Commit Subject:%cgreen%s%creset%n ' "
Note: The command%_ce,%_CD,%_cblue respectively Remove the underscore _.
$git LG
* 38896a27dc8ab4f47883bd67d300f6145f0478b7 @ (HEAD, master)
| Author:eddy <[email protected]>
| Date:thu Feb 2 17:06:06 +0800 (8 days ago)
|
| Commit Subject:commit Write 2
|
* 7D3E94CF22B17F7D097479AE8D9367E42509BB3F @
Author:eddy <[email protected]>
Date:thu Feb 2 17:05:00 +0800 (8 days ago)
Commit Subject:initial Commit
4) Other options
Git log supports a lot of options, please refer to git log--help, commonly used (reference (1) in table 2-2):
Option description
-P Displays the difference between each update in a patched format.
--STAT Displays the file modification statistics for each update.
--shortstat only displays the last number of rows in the--stat modified to add remove statistics.
--NAME-ONLY Displays the modified list of files only after the information is submitted.
--name-status displays a list of new, modified, and deleted files.
--abbrev-commit displays only the first few characters of the SHA-1, not all 40 characters.
--relative-date uses a shorter relative time display (for example, "2 weeks Ago").
--graph Displays the branch merge history represented by the ASCII graphic.
--pretty Displays historical submission information in other formats. The available options are Oneline,short,full,fuller and format (followed by the specified format).
Resources:
(1) http://progit.org/book/zh/ch2-3.html
(2) http://ruby-china.org/topics/939
(3) Http://linux.die.net/man/1/git-show
1. View Commit History