The git log command of git can still play like this

Git is currently a very popular library management tool, and git log is also an important command

Why are there so many articles on the Internet, I have to record one, because what I write is what I often use, is practical, and will tell everyone their logic and reasoning

Here are a few useful commands

1. Display the log of the previous 2 commits

git log -2

2. Display the details of the last submitted code

git log -1 -p

3. Display brief information about the latest submitted code

git log -1 --stat 

4. Display super brief information (hash and commen) of the last submitted code

 git log -1 --pretty=oneline

 5. A usage of takeoff that we will use

git log --pretty='%h - %an - %s' 

 The specific representatives are as follows:

%H

The full hash of the commit

%h

The shorthand hash of the commit

%T

the full hash of the tree

%t

Shorthand hash of the tree

%P

The full hash of the parent commit

%p

Shorthand hash of the parent commit

%an

author name

%ae

Author's email address

%ad

author revision date (format can be customized with --date= option)

%ar

Author revision date, shown in order of how far back

%cn

submitter's name

%ce

Submitter's email address

%cd

submission date

%cr

Submission date (how long ago)

%s

Submission instructions

 6. Added some ASCII strings to visually display your branch and merge history

git log --pretty="%h %s" --graph

 7. Let’s look at a practical example. If you want to check which submission of Junio ​​C Hamano modified the test file during 2008.10.1 - 2008.11.1 in the Git source code repository, you can use the following command:

$ git log --pretty="%h - %s" --author='Junio C Hamano' --since="2008-10-01" \
   --before="2008-11-01" --no-merges -- test-dir/
5610e3b - Fix testcase failure when extended attributes are in use
acd3b9e - Enhance hold_lock_file_for_{update,append}() API
f563754 - demonstrate breakage of detached checkout with symbolic link HEAD
d1a43f2 - reset --hard/read-tree --reset -u: remove unmerged new paths
51a94af - Fix "checkout --track -b newbranch" on detached HEAD
b0ad11e - pull: allow "git pull origin $something:$current_branch" into an unborn branch

Out of almost 40,000 commits, the above output only lists 6 records that met the criteria.

This command is generally used for troubleshooting. When multiple people develop the same project, some of our codes are accidentally modified when merging and repairing conflicts. Then we can troubleshoot based on this

8. Supplement: Of course, if you need to find this person who has modified a certain content of ours, you can use filtering

For example, we need to find and modify the hash of our xxx content, (-G can be followed by regular expressions)

git log -S 'xxx' --pretty='%H'

It's 12 o'clock, I'm still studying, why don't you work hard? 

Guess you like

Origin blog.csdn.net/weixin_42335036/article/details/122974672