git 在 Magit 中查看文件的历史记录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14352932/
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
View a file's history in Magit?
提问by eugene
View the change history of a file using Git versioningtalks about other ways of viewing history of a file in Git.
使用 Git 版本控制查看文件的更改历史讨论了在 Git 中查看文件历史的其他方法。
Can it be done in Emacs Magit?
可以在 Emacs Magit 中完成吗?
回答by Ragge
Since magit 2.1: magit-log-buffer-file
(as per comment below)
从 magit 2.1 开始:(magit-log-buffer-file
根据下面的评论)
Before magit 2.1: magit-file-log
is what you are looking for. It will show you all commits for the file in the current buffer in the standard magit log view.
在 magit 2.1 之前:magit-file-log
就是你要找的。它将在标准 magit 日志视图中显示当前缓冲区中文件的所有提交。
回答by Bryan Ash
Open your magit-status
buffer, by typing M-x magit-status
(I used to have this bound to C-. C-g
because it is used all the time. These days, I use Spacemacs so it's <SPC> g s
)
magit-status
通过键入打开您的缓冲区M-x magit-status
(我曾经绑定过C-. C-g
它,因为它一直在使用。这些天,我使用 Spacemacs 所以它是<SPC> g s
)
- Type
l
to get log viewing option - Type
--
to set the "Limit to files" option (used to be=f
) - Enter the file path you wish to view history for
- Type
l
to view the log of the current branch
- 键入
l
以获取日志查看选项 - 键入
--
以设置“限制到文件”选项(曾经是=f
) - 输入要查看历史记录的文件路径
- 键入
l
查看当前分支的日志
If you're using Spacemacs, you can get the history of the currently visited file using <SPC> g f h
如果您使用的是 Spacemacs,则可以使用以下命令获取当前访问过的文件的历史记录 <SPC> g f h
回答by Bart Vandendriessche
In your *magit: <project>*
buffer use l
to go into logging mode, then press f
to be prompted for a filename.
在您的*magit: <project>*
缓冲区中使用l
进入日志记录模式,然后按f
提示输入文件名。
回答by sp3ctum
I do not know a way. I simply use M-x vc-print-log
which seems to accomplish the same feat. It is not a magit-integrated way, though.
我不知道有什么办法。我只是使用M-x vc-print-log
它似乎完成了同样的壮举。不过,这不是一种与 magit 集成的方式。
回答by VonC
If magit(user manual) doesn't have that feature, then you can have a look at other Emacs mode, and add you own git-log-file
function:
如果magit(用户手册)没有该功能,那么您可以查看其他Emacs模式,并添加您自己的git-log-file
功能:
(defun git-log-file ()
"Display a log of changes to the marked file(s)."
(interactive)
(let* ((files (git-marked-files))
(buffer (apply #'git-run-command-buffer "*git-log*" "git-rev-list" \
"--pretty" "HEAD" "--" (git-get-filenames files)))) (with-current-buffer buffer
; (git-log-mode) FIXME: implement log mode
(goto-char (point-min))
(setq buffer-read-only t))
(display-buffer buffer)))