git log命令_Git Log命令解释

git log命令

git log有什么作用? (What does git log do?)

The git log command displays all of the commits in a repository’s history.

git log命令显示存储库历史记录中的所有提交。

By default, the command displays each commit’s:

默认情况下,该命令显示每个提交的:

  • Secure Hash Algorithm (SHA)

    安全哈希算法(SHA)
  • author

    作者
  • date

    日期
  • commit message

    提交消息

Git uses the Less terminal pager to page through the commit history. You can navigate it with the following commands:

Git使用Less终端寻呼机来翻阅提交历史记录。 您可以使用以下命令浏览它:

  • to scroll down by one line, use j or ↓

    向下滚动一行,使用j或↓
  • to scroll up by one line, use k or ↑

    向上滚动一行,请使用k或↑
  • to scroll down by one page, use the spacebar or the Page Down button

    要向下滚动一页,请使用空格键或Page Down按钮
  • to scroll up by one page, use b or the Page Up button

    要向上滚动一页,请使用b或Page Up按钮
  • to quit the log, use q

    要退出日志,请使用q

Git日志标志 (Git Log Flags)

You can customize the information presented by git log using flags.

您可以使用标志来自定义git log呈现的信息。

-一条线 (—oneline)

git log --oneline

git log --oneline

The --oneline flag causes git log to display

--oneline标志使git log显示

  • one commit per line

    每行一次提交
  • the first seven characters of the SHA

    SHA的前七个字符
  • the commit message

    提交消息

–stat (—stat)

git log --stat

git log --stat

The --stat flag causes git log to display

--stat标志导致git log显示

  • the files that were modified in each commit

    每次提交中修改的文件
  • the number of lines added or removed

    添加或删除的行数
  • a summary line with the total number of files and lines changed

    摘要行,其中文件和行的总数已更改

-patch或-p (—patch or -p)

git log --patch

git log --patch

or, the shorter version

或者,较短的版本

git log -p

git log -p

The --patch flag causes git log to display

--patch标志使git log显示

  • the files that you modified

    您修改的文件
  • the location of the lines that you added or removed

    您添加或删除的行的位置
  • the specific changes that you made

    您所做的特定更改

查看作者指定的提交次数 (View specified number of commits by author)

To view a specified number of commits by an author to the current repo (optionally in a prettified format), the following command can be used

要查看作者对当前存储库的指定提交次数(可选,以预设格式),可以使用以下命令

git log --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" -n {NUMBER_OF_COMMITS} --author="{AUTHOR_NAME}" --all

git log --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" -n {NUMBER_OF_COMMITS} --author="{AUTHOR_NAME}" --all

从特定的提交开始 (Start at a specific commit)

To start git log at a specific commit, add the SHA:

要在特定提交时启动git log ,请添加SHA:

git log 7752b22

git log 7752b22

This will display the commit with the SHA 7752b22 and all of the commits made before that commit. You can combine this with any of the other flags.

这将显示带有SHA 7752b22的提交以及在该提交之前进行的所有提交。 您可以将其与其他任何标志结合使用。

-图形 (—graph)

git log --graph

git log --graph

The --graph flag enables you to view your git log as a graph. To make things things interesting, you can combine this command with --oneline option you learned from above.

使用--graph标志可以将git log查看为图形。 为了使事情变得有趣,可以将此命令与从上面学到的--oneline选项结合使用。

git log --graph --oneline

git log --graph --oneline

The output would be similar to,

输出将类似于

* 64e6db0 Update index.md
* b592012 Update Python articles (#5030)
* ecbf9d3 Add latest version and remove duplicate link (#8860)
* 7e3934b Add hint for Compose React Components (#8705)
* 99b7758 Added more frameworks (#8842)
* c4e6a84 Add hint for "Create a Component with Composition" (#8704)
*   907b004 Merge branch 'master' of github.com:freeCodeCamp/guide
|\  
| * 275b6d1 Update index.md
* |   cb74308 Merge branch 'dogb3rt-patch-3'
|\ \  
| |/  
|/|   
| *   98015b6 fix merge conflicts after folder renaming
| |\  
|/ /  
| * fa83460 Update index.md
* | 6afb3b5 rename illegally formatted folder name (#8762)
* | 64b1fe4 CSS3: border-radius property (#8803)

One of the benefit of using this command is that it enables you to get a overview of how commits have merged and how the git history was created.

使用此命令的好处之一是,它使您能够大致了解提交的合并方式以及git历史记录的创建方式。

There are may other options you could use in combination with --graph. Couple of them are --decorate and --all. Make sure to try these out too. And you can refer to the documentation for more helpful info.

您还可以将其他选项与--graph结合使用。 他们中的--decorate--decorate--all 。 确保也尝试这些。 您可以参考文档以获取更多有用信息。

更多信息: (More Information:)

其他关于Git的资源 (Other Resources on Git )

翻译自: https://www.freecodecamp.org/news/git-log-command/

git log命令

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值