Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to Git Foundation (4) Git History Management

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

git clone https://github.com/schacon/simplegit-progit mytest #Get test items

cd mytest

git log #View log information for Git repositories

commit ca82a6dff817ec66f44342007202690a93763949

Author: Scott Chacon

Date: Mon Mar 17 21:52:11 2008 -0700

changed the verison number

commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7

Author: Scott Chacon

Date: Sat Mar 15 16:40:33 2008 -0700

removed unnecessary test code

commit a11bef06a3f659402fe7563abf99ad00de2209e6

Author: Scott Chacon

Date: Sat Mar 15 10:31:28 2008 -0700

first commit

The git log lists all updates by submission time, listing the checksum of each submission, the author's name and email address, the submission time, and the submission description.

git log has many options to help you find the information you are looking for. Here are some of the most commonly used.

-p: Shows content differences for each submission

-N: Displays the most recent N submissions

git log -p -1

commit ca82a6dff817ec66f44342007202690a93763949

Author: Scott Chacon

Date: Mon Mar 17 21:52:11 2008 -0700

changed the verison number

diff --git a/Rakefile b/Rakefile

index a874b73.. 8f94139 100644

--- a/Rakefile

+++ b/Rakefile

@@ -5,7 +5,7 @@ require 'rake/gempackagetask'

spec = Gem::Specification.new do |s|

s.platform = Gem::Platform::RUBY

s.name = "simplegit"

- s.version = "0.1.0"

+ s.version = "0.1.1"

s.author = "Scott Chacon"

s.email = "schacon@gmail.com"

s.summary = "A simple gem for using Git in Ruby code. "

--stat: Displays abbreviated statistics for each submission

git log --stat -1

commit ca82a6dff817ec66f44342007202690a93763949

Author: Scott Chacon

Date: Mon Mar 17 21:52:11 2008 -0700

changed the verison number

Rakefile | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

--pretty=: Specifies that submission history is presented in a different format than the default

format:

oneline displays each submission on a single line, useful when viewing a large number of submissions

full: View author and submitter (modifier)

fuller: outputs more detailed information than full (submitter)

git log --pretty=oneline

ca82a6dff817ec66f44342007202690a93763949 changed the verison number

085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test code

a11bef06a3f659402fe7563abf99ad00de2209e6 first commit

git log --pretty=full -1

commit ca82a6dff817ec66f44342007202690a93763949

Author: Scott Chacon

Commit: Scott Chacon

changed the verison number

git log --pretty=fuller -1

commit ca82a6dff817ec66f44342007202690a93763949

Author: Scott Chacon

AuthorDate: Mon Mar 17 21:52:11 2008 -0700

Commit: Scott Chacon

CommitDate: Fri Apr 17 21:56:31 2009 -0700

changed the verison number

git log --pretty=format #Customize the format of records to be displayed

git log --pretty=format:"%h - %an, %ar : %s"

ca82a6d - Scott Chacon, 10 years ago : changed the verison number

085bb3b - Scott Chacon, 10 years ago : removed unnecessary test code

a11bef0 - Scott Chacon, 10 years ago : first commit

option descriptions

%H Submit the full hash string of the object

%h Short hash string of submission object

%T Complete hash string of tree object

% tShort hash string of tree object

%P Full hash string of parent object

%p Short hash string of parent object

%an Author's name

%ae Author's email address

%ad Author revision date (can be formatted with--date= option)

%ar Author revision date, displayed by how long ago

%cn Name of submitter

%ce Email address of submitter

%cd Date Submitted

%cr Date submitted, displayed as how long ago

%s Submit Description

When oneline or format is used in conjunction with another log option, --graph, this option adds ASCII strings to visualize your branching and merging history.

git log --pretty=oneline --graph

* ca82a6dff817ec66f44342007202690a93763949 changed the verison number

* 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test code

* a11bef06a3f659402fe7563abf99ad00de2209e6 first commit

git log #Displays only historical information for specified paths or files

git log README

commit a11bef06a3f659402fe7563abf99ad00de2209e6

Author: Scott Chacon

Date: Sat Mar 15 10:31:28 2008 -0700

first commit

Common options for git log

option descriptions

-p Displays differences between each update in patch format

-N N stands for a number indicating that the first N messages are displayed.

--stat Displays file modification statistics for each update

--shortstat shows only the last rows in--stat modify add remove statistics

--name-only Show modified file list only after submitting information

--name-status Displays a list of files added, modified, or deleted

--abbrev-commit displays only the first few characters of the checksum, not all 40 characters

--relative-date Use shorter relative time display

--graph Displays branch merge history represented graphically in ASCII

--pretty Displays historical submissions in other formats. Available options include oneline, full, fuller, and format(followed by the specified format)

--since Displays commits after a specified time.

--until Displays submissions before the specified time.

--author Displays submissions related to the specified author.

--committer Displays submissions related to the specified committer.

--grep Displays submissions with specified keywords

-S Displays submissions with a keyword added or removed

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report