[Software testing] Git checks the submission history of commit (detailed) with one click...


foreword

How to view the commit history
After submitting several updates, or cloning a project, how to view the commit history

git log 

Official example:
Run the following command to get the project:

git clone https://github.com/scha

Run the git log command

A1

The information that can be obtained
By default, without passing in any parameters, git log will list all submissions in chronological order, with the latest update at the top; it
will list the SHA-1 checksum of each submission, Author's name and email address, time of submission, and submission instructions;

Common command line parameters of git log
-p, –patch: it will display the difference introduced by each submission (output in the format of patch);
-n: n is the number, which limits the number of logs displayed, such as -2, output two ;

A2

-p In addition to displaying the basic information, it also includes the changes of each submission. The advantage: when performing code review, you can quickly see the differences in the code submitted by others

--stat
see brief statistics for each commit

A3

Below each commit is a list of all modified files, how many files were modified, and which lines of the modified files were removed or added

--pretty
can use different formats to display the commit history, and there are some built-in sub-options for you to use.

A4

--pretty=oneline
displays each commit on one line, very useful when browsing a large number of commits

A5

There are also short, full and fuller options, which display information in basically the same format, but with different degrees of detail

–pretty=format
can customize the display format of records

Such output is especially useful for post-extraction analysis, because the format of the output will not change with Git updates

A6

git log --pretty=format Commonly used options
List the common format placeholders accepted by format and their meanings

options illustrate
%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

Especially useful when oneline or format are combined with another log option --graph, to show your branch and merge history:

git log --pretty=format:"%h %s" --graph
* 2d3acf9 ignore errors from SIGCHLD on trap
*  5e3ee11 Merge branch 'master' of git://github.com/dustin/grit
|\
| * 420eac9 Added a method for getting the current branch.
* | 30e367c timeout code and tests
* | 5a09431 add timeout protection to grit
* | e1193f8 support for heads with slashes in them
|/
* d6016bc require time for xmlschema
*  11d191e Merge branch 'defunkt' into local

Common options for git log output format

options illustrate
-p Shows the diffs introduced by each commit in patch format.
–stat Display file modification statistics for each commit.
–shortstat Show only the last line count in --stat Modify add remove stats.
–name-only Show modified file list only after submitting information.
–name-status Display the list of newly added, modified and deleted files.
–abbrev-commit Only the first few characters of all 40 characters of the SHA-1 checksum are displayed.
–relative-date Display dates using short relative times instead of full format (like "2 weeks ago").
–graph Displays branch and merge history in ASCII graphics alongside the log.
–pretty Use a different format to display historical commit information. Available options include oneline, short, full, fuller, and format (to define your own format).
–oneline Shorthand for --pretty=oneline --abbrev-commit.

Limit output length

-n: limit the number of output commit history
–since, –until: limit by time

The following command will list all commits from the last two weeks

git log --since=2.weeks

The format available for this command is very rich.
It can be a specific day like "2008-01-15", or a relative date like "2 years 1 day 3 minutes ago".

git lot option to limit output

options illustrate
-<n> Only show the most recent n commits.
–since, --after Only show commits after the specified time.
–until, --before Only show commits older than the specified time.
–author Show only commits whose author matches the specified string.
–committer Show only commits whose committer matches the specified string.
–grep Show only commits with the specified string in their commit description.
-S Show only commits with additions or removals matching the specified string.
Show only historical commits for certain files or directories, --filename/dirname
–no-merges Do not show history for merge commits

A practical example:
If you want to see in the Git source code repository which commits Junio ​​Hamano made during October 2008, other than the merge commit, modified the test file, 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 -- t/
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
The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled

1. From entry to mastery of Python programming

Please add a picture description

2. Interface automation project actual combat

Please add a picture description

3. Actual Combat of Web Automation Project

Please add a picture description

4. Actual Combat of App Automation Project

Please add a picture description

5. Resume of first-tier manufacturers

Please add a picture description

6. Test and develop DevOps system

Please add a picture description

7. Commonly used automated testing tools

Please add a picture description

Eight, JMeter performance test

Please add a picture description

9. Summary (little surprise at the end)

Only with unremitting efforts and perseverance can we create a brilliant chapter in life. No matter how difficult the road ahead is, as long as we have courage and faith, we will be able to overcome difficulties and realize our ideals and dreams. Believe in yourself and keep fighting!

Only those who have experienced hardships can reap real growth; only those who embrace challenges can march towards a brilliant future. Believe in your own strength, go forward bravely, and every effort is paving the way for a better tomorrow. come on!

Only with the courage and persistence to constantly surpass oneself can we open up endless possibilities. On the way of chasing dreams, setbacks and difficulties are the catalysts for growth, and struggle is the only password to success. Believe in yourself, burn the flame in your heart, you will create your own brilliance!

Guess you like

Origin blog.csdn.net/shuang_waiwai/article/details/131623386
Recommended