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

How to see what has changed in the Git submission

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to see what has changed in Git submission". The explanation in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how to see what has changed in Git submission".

View the changes in the file in the submission

To know which files have changed in the specified submission, you can use the git log-- raw command. This is the quickest and most convenient way to find out which files are affected by submission. The git log command is generally underutilized, mainly because it has too many formatting options, and many users are deterred by many choices and in some cases unknown documents.

However, Git's logging mechanism is very flexible, and the-- raw option provides the commit log in the current branch, as well as a list of changed files.

The following is the standard git log output:

$git logcommit fbbbe083aed75b24f2c77b1825ecab10def0953c (HEAD-> dev, origin/dev) Author: tux Date: Sun Nov 5 21:40:37 2020 + 1300 exit immediately from failed download commit 094f9948cd995acfc331a6965032ea0d38e01f03 (origin/master, master) Author: Tux Date: Fri Aug 5 02:05:19 2020 + 1200 export makeopts from etc/example.conf commit 76b7b46dc53ec13316abb49cc7b37914215acd47Author: Tux Date: Sun Jul 31 21:45:24 20 fix typo in help message

Even if the author specifies which files have changed in the submission message, the log is fairly concise.

The following is the git log-- raw output:

Git log-- rawcommit fbbbe083aed75b24f2c77b1825ecab10def0953c (HEAD-> dev, origin/dev) Author: tux Date: Sun Nov 5 21:40:37 2020 + 1300 exit immediately from failed download: 100755 100755 cbcf1f3 4cac92f M src/example.lua commit 094f9948cd995acfc331a6965032ea0d38e01f03 (origin/master Master) Author: Tux Date: Fri Aug 5 02:05:19 2020 + 1200 export makeopts from etc/example.conf: 100755 100755 4c815c0 cbcf1f3 M src/example.lua:100755 100755 71653e1 8f5d5a6 M src/example.spec:100644 100644 9d21a6f e33caba R100 etc/example.conf etc/example.conf-default commit 76b7b46dc53ec13316abb49cc7b37914215acd47Author: Tux Date: Sun Jul 31 21:45:24 20 fix typo in help message: 100755 100755 e253aaf 4c815c0 M src/example.lua

This will tell you exactly which files are added to the submission and which files have changed (An is added, M is modified, R is renamed, D is deleted).

Git whatchanged

The git whatchanged command is a legacy command that was formerly known as the logging function. The documentation says that users should not replace git log-raw with this command, and implies that it has essentially been abandoned. However, I still find it a useful shortcut to get the same output (although the merge submission is not included), and if it is deleted, I intend to create an alias for it. If you only want to view changed files and don't want to see merge commits in the log, try git whatchanged as a simple mnemonic.

View changes

Not only can you see which files have changed, but you can also use git log to show what changes have taken place in the files. Your Git log can generate an inline difference, and all changes to each file can be displayed line by line with the-- patch option:

Commit 62a2daf8411eccbec0af69e4736a0fcf0a469ab1 (HEAD-> master) Author: Tux Date: Wed Mar 1006: 46:58 2021 + 1300 commit diff-- git a/hello.txt b/hello.txtindex 65a56c3..36a0a7d 100644 Muhammad-a gray hello.txthands @-1meme 2 + 1jue 2 @ @ Hello-world+opensource.com

In this example, the word "world" is deleted from the hello.txt and the line "opensource.com" is added.

If you need to make the same changes manually elsewhere, these can be used with common Unix commands, such as diff and patch. Patches are also a good way to summarize important parts of the specified submission that introduce new information. When you introduce a bug during the sprint phase, you will find that the content here is a very valuable overview. In order to find the cause of the error more quickly, you can ignore the parts of the file that have not changed and just check the new code.

Get complex results with simple commands

You don't have to understand references, branches, and commit hashes to see which files have been changed in the submission. Your Git log is designed to report Git activities to you, and if you want to format it or extract specific information in a specific way, you usually need to browse through many documents to combine the correct commands. Fortunately, one of the most common requests for Git history requires only one or two options:-- raw and-- patch. If you don't remember-- raw, just think, "Git, what changed?" , and enter git whatchanged.

Thank you for your reading, the above is the content of "how to see what has changed in Git submission". After the study of this article, I believe you have a deeper understanding of how to view what has changed in Git submission, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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