在 emacs 中使用提交详细信息进行 git 责备
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15460550/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git blame with commit details in emacs
提问by Robin Green
From emacs, how can I see the details (e.g. commit message) of the commit that last changed the line at point?
在 emacs 中,如何查看最后更改该行的提交的详细信息(例如提交消息)?
I have magit installed.
我已经安装了magit。
回答by Robin Green
It is not necessary to use magit for this particular operation - vanilla emacs can do it.
对于这个特定的操作,没有必要使用 magit - vanilla emacs 可以做到。
(Also, because this uses vc, this should work identically in any version control system that vc supports.)
(此外,因为它使用了 vc,所以这在 vc 支持的任何版本控制系统中都应该相同。)
First, use the vc-annotate
command, which is bound to the key sequence C-xvg.
首先,使用vc-annotate
与键序列绑定的命令C-xvg。
Now, the point should be at the commit id that you are interested in. (If not, you might need to use C-x1and/or vso that you can see which line is which, in order to navigate to the right one.) You might be able to see the diff for that file using =now - if you get an error beginning with "cannot diff from any revision prior...", that probably means that this revision created the file (and that's probably a bug in emacs).
现在,重点应该是您感兴趣的提交 ID。(如果没有,您可能需要使用C-x1和/或v以便您可以看到哪一行是哪一行,以便导航到正确的行。)您可能能够使用=now查看该文件的差异- 如果您收到以“无法与之前的任何修订版进行差异...”开头的错误,这可能意味着该修订版创建了该文件(这可能是 emacs 中的错误)。
The author and date are already visible in the Annotatebuffer that vc-annotate
produced.
作者和日期已经在生成的Annotate缓冲区中可见vc-annotate
。
To see the commit message, press l(the letter, not the number 1) in the Annotatebuffer. To see what the file looked like at that revision, press fin either the Annotatebuffer or the vc-change-logbuffer.
要查看提交消息,请l在Annotate缓冲区中按(字母,而不是数字 1)。要查看该文件看起来像在该版本中,按f无论是在注释缓冲区或VC-变化日志缓冲区。
回答by Bozhidar Batsov
I'd suggest the use of magit-blame-mode
(M-x magit-blame-mode). It provides the information in much nicer manner compared to vc-annotate
and is part of the standard magit distribution. You'd probably want to bind it to some keyboard combination to toggle it quickly.
我建议使用magit-blame-mode
( M-x magit-blame-mode)。vc-annotate
与标准 magit 发行版相比,它以更好的方式提供信息,并且是标准 magit 发行版的一部分。您可能希望将其绑定到某个键盘组合以快速切换它。
In magit-blame-mode
use pand nto navigate between the previous and the next change and RETto see the diff for a particular commit.
在magit-blame-mode
使用中p并n在上一个和下一个更改之间导航并RET查看特定提交的差异。