Introduction to GIT Usage-2

Source: Internet
Author: User

Then the previous article, introducing some GIT usage

In the previous article introduced the kick, are basic operations, the project along the way what happened, you should have a general understanding of it, today to introduce how to view the history of the submission

git log

This command will output a branch, from the beginning to now each commit what happened, the default is to put the latest submission on the top, convenient for everyone, the following simple to say its several common parameters

-P: Compare the differences between submissions, you can keep up with-N, like Git log-p -2/-3, which is handy when doing code reviews, and you can see what other collaborators have changed

--stat: Only shows statistics on the number of row increases

--pretty: Can be assigned, there are Oneline,short,full,fuller,format oneline is very useful, which is very helpful when the number of submissions is very large, there is a very interesting, is the format, for example

git log--pretty=format: "%h-%an,%ar:%s", and make a list of commonly used placeholders:

Options Description
%H Full hash string for commit object (commit)
%h A short hash string for the Commit object
%T Full hash string for tree object
%t A short hash string for a tree object
%P Full hash string for parent object
%p Short hash string for parent object
%an
The name of the author (author)
%ae Author's e-mail address
%ad Author revision date (can be customized with-date= option)
%ar Author revision date, as of how long ago the way display
%cn The name of the submitter (committer)
%ce Submitter's e-mail address
%cd Date submitted
%cr Submission date, as of how long ago the way it was displayed
%s Submission Instructions

Let's list the common options for git log, and try to test them yourself.

-P: Show the difference between each update by patch format

--stat: Show file modification statistics for each update

--shortstat: Show only the last number of lines in--stat Modify 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, deleted files

--abbrev-commit: Displays only the first few characters of the SHA-1, not all 40 characters

--relative-date: Using a shorter relative time display (for example, "2 weeks Ago")

--graph: Shows the branch merge history of the graphic representation of ASCII

--pretty: Display historical submissions in other formats, as explained in the following parameters


Git log also has a bit better feature: limit the output length

The time-based options, such as--since and--until, can be used to

git log--since=2.weeks, git log--since= "2016-05-25" to specify the later time

A similar match would be:

-(n): Show only the most recent n submissions

--since,--after: Show only commits after a specified time

--until,--before: Show only commits before the specified time

--auther: Show only relevant submissions for the specified author

--committer: Show only submissions related to the specified submitter


The following comprehensive use: Git log--pretty= "%h:%s"--AUTHER=WXL--since= "2016-05-24"--before= "2016-05-25"--no-merges--t/about the command at the end of the description, t/is the file under the Project t/directory, which is in front of it--to make the path separate from the previous options

This is the day, the usual commands should be more familiar.

Introduction to GIT Usage-2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.