|
Git multi-color output
Git default output is a single color, not only not beautiful, not easy to read. In fact, Git support itself in a variety of colors to display the information on its output, simply run the following command at the command line to modify the git setup, you can open multiple color output:
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
After executing the above command, git's status, diff command and branch and so on are all output with the color.
Custom log format
After completing the above steps, git log command output, although with a little color, but still seems boring ..
It does not matter, the powerful git provides custom log format features, try entering the following command:
git log --graph --pretty = format: '% Cred% h% Creset -% C (yellow)% d% Creset% s% Cgreen (% cr)% C (bold blue) <% an>% Creset' - -abbrev-commit
How, not bad, right? However, each time you view log output so are a long list of commands, it is not realistic. Let's solve this problem by git command aliases. Enter the following command:
git config --global alias.lg "log --graph --pretty = format: '% Cred% h% Creset -% C (yellow)% d% Creset% s% Cgreen (% cr)% C (bold blue) <% an>% Creset ' "
The above command will create a command alias lg, every time you use the command git lg equivalent to just enter the long list of commands. Now, if you want to see beautiful multi-color output, use git lg, if you want to see the normal log output, use git log, the two non-interfering.
If you want to log the output of certain information, you can adjust their value --pretty parameters, for example, the following command will display only commit the hash, commit time, the author's name:
git log --pretty = format: '% h% ar% an'
The format back single quotes replaces the format you want, you can implement custom log output format. Here% h,% ar, etc. are some of the git predefined placeholder for a complete list is as follows:
% H commit hash
Short hash% h commit the
% T tree hash
Short hash% t tree of
% P parent hashes
Short hashes% p parent of
% An Author name
% AN mailmap corresponding name of the author (.mailmap correspondence, details refer git-shortlog (1) or git-blame (1))
% Ae OF mailbox
% AE OF mailbox (.mailmap correspondence, details refer git-shortlog (1) or git-blame (1))
% Ad date (-date = format developed)
% AD date, RFC2822 format
% Ar date relative format (1 day ago)
% At the date, UNIX timestamp
% Ai dates, ISO 8601 format
% Cn submitter name
% CN submitter name (.mailmap correspondence, details refer git-shortlog (1) or git-blame (1))
% Ce Submitted by email
% CE submitted by email (.mailmap correspondence, details refer git-shortlog (1) or git-blame (1))
% Cd filing date (-date = format developed)
% CD submission date, RFC2822 format
% Cr submission date and relative format (1 day ago)
% Ct submission date, UNIX timestamp
% Ci submission date, ISO 8601 format
% D ref name
% E encoding
% S commit Title
% F filter commit information to make the title as the file name
% B commit content
% N commit notes
% GD reflog selector, e.g., refs / stash @ {1}
% Gd shortened reflog selector, e.g., stash @ {1}
% Gs reflog subject
% Cred switch to red
% Cgreen switch to green
% Cblue switch to blue
% Creset Reset color
% C (...) to develop color, as described in color.branch. * Config option
% M left, right or boundary mark
% N newline
%% A raw%
% X00 print a byte from a hex code
% W ([< w> [, < i1> [, < i2>]]]) |
|
|
|