magit: how to diff the same file between two different commits on the same branch?

后端 未结 3 1302
走了就别回头了
走了就别回头了 2021-01-02 01:21

How can I get the diff between two commits of the same file using magit?

Directly form git one can do this. But I don\'t k

3条回答
  •  庸人自扰
    2021-01-02 02:06

    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):

    1. Type d to open the magit-diff-popup
    2. Type =f to specify the file you want to view (enter path relative to the project root dir)
    3. 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.

    This way, you end up in a magit-diff buffer complete with highlighting and code folding.

提交回复
热议问题