magit:如何在同一分支的两次不同提交之间区分同一文件? [英] magit: how to diff the same file between two different commits on the same branch?
问题描述
如何使用 magit
获得两次相同提交之间的差异?
How can I get the diff between two commits of the same file using magit
?
直接形成 git
可以此。但我不知道如何从 magit
内完成此操作。从 magnet-status
看来, d
和 D
返回整个存储库的差异。这对我来说是个很大的问题,因为存储库巨大且会导致 magit
(进而导致 emacs
)变得无响应。有没有办法让 magit
将搜索限制为仅存储库中的一个文件?
Directly form git
one can do this. But I don't know how to do it from within magit
. From magit-status
it seems that d
and D
returns the diff of the whole repository. This is very problematic for me as the repository is huge and it causes magit
(and in turn emacs
) to become unresponsive. Is there a way to ask magit
to restrict the search to only one file from the repository?
我也尝试过,在 magit-status
缓冲区中执行:diff $ start_commit .. $ end_commit-路径/至/文件
。这可行,但输出是一个简单的缓冲区,没有任何突出显示或任何折叠选项...
I also tried, in the magit-status
buffer to do : diff $start_commit..$end_commit -- path/to/file
. This works, but the output is a simple buffer without any highlighting nor any folding options...
推荐答案
万一有人偶然发现现在,可以在magit中执行此操作(我从magit-log中执行此操作,但是您也可以从其他位置执行此操作):
In case anyone stumbles across this now, it is now possible to do this in magit (I do this from magit-log but you can probably do it from elsewhere, too):
- 键入
d
打开magit-diff-popup - 键入
= f
指定要查看的文件(输入相对于项目根目录的路径) - 键入
r
来执行差异范围。您将被要求提供提交范围,例如,4abcde2..HEAD
。或者,如果您在magit-log中突出显示提交范围,则会自动为您设置该范围,而不会提示您。
- Type
d
to open the magit-diff-popup - Type
=f
to specify the file you want to view (enter path relative to the project root dir) - Type
r
to do a diff range. You will be asked for the commit range, for example,4abcde2..HEAD
. Alternately, if you highlight the range of commits in magit-log, the range will be set for you automatically with no prompt.
此这样,您最终将进入一个具有突出显示和代码折叠功能的magit-diff缓冲区。
This way, you end up in a magit-diff buffer complete with highlighting and code folding.
这篇关于magit:如何在同一分支的两次不同提交之间区分同一文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!