blame git_Git Blame用示例解释

blame git

With git blame you can see who changed what in a specific file, line by line, which is useful if you work in a team, instead of alone. For example, if a line of code makes you wonder why it is there, you can use git blame and you will know who you must ask.

使用git blame您可以看到谁逐行更改了特定文件中的内容,这对于团队合作而不是一个人工作很有用。 例如,如果一行代码使您想知道为什么会有代码,则可以使用git blame ,您将知道必须询问谁。

用法 (Usage)

You use git blame like this: git blame NAME_OF_THE_FILE

您可以这样使用git blamegit blame NAME_OF_THE_FILE

For example: git blame triple_welcome.rb

例如: git blame triple_welcome.rb

You will see an output like this:

您将看到类似以下的输出:

0292b580 (Jane Doe      2018-06-18 00:17:23 -0500 1) 3.times do
e483daf0 (John Doe      2018-06-18 23:50:40 -0500 2)   print 'Welcome '
0292b580 (Jane Doe      2018-06-18 00:17:23 -0500 3) end

Each line is annotated with the SHA, name of the author and date of the last commit.

每行都用SHA,作者姓名和最后提交日期注释。

别名Git责备 (Aliasing Git Blame)

Some programmers don’t like the word ‘blame’, because of the negative connotation ‘blaming someone’ brings with it. Also, the tool is rarely (if ever) used for blaming someone, but rather to ask for advice or understand the history of a file. Therefore, sometimes people use an alias to change git blame to something which sounds a bit nicer such as git who, git history or git praise. To do that you simply add a git alias like this:

一些程序员不喜欢“责备”一词,因为它带有负面含义“责备某人”。 而且,该工具很少(如果有的话)用来指责某人,而是寻求建议或了解文件的历史记录。 因此,有时人们使用别名将git blame更改为听起来更好的东西,例如git whogit historygit praise 。 为此,您只需添加一个git别名,如下所示:

git config --global alias.history blame

git config --global alias.history blame

You can find more information about aliasing git commands here.

您可以在此处找到有关别名git命令的更多信息。

利用Git Blame的文本编辑器插件 (Text Editor Plugins utilizing Git Blame)

There are a few plugins out there for various text editors which utilize git blame. For example, to create something like heat maps or add inline information for the current line you are inspecting. A famous example is GitLense for VSCode.

有一些插件git blame各种文本编辑器使用。 例如,要创建诸如热图之类的东西或为您要检查的当前管线添加内联信息。 一个著名的例子是VSCode的GitLense。

翻译自: https://www.freecodecamp.org/news/git-blame-explained-with-examples/

blame git

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值