用gvimdiff來顯示diff+我喜歡的

來源:互聯網
上載者:User

http://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-visual-diff-program

The second method, which I prefer, is to configure the external diff tool via "gitconfig". Here's what I did:

1) Create a wrapper script "git-diff-wrapper.sh" which contains something like

-->8-(snip)--#!/bin/sh# diff is called by git with 7 parameters:# path old-file old-hex old-mode new-file new-hex new-mode"<path_to_diff_executable>" "$2" "$5" | cat--8<-(snap)--

As you can see, only the second ("old-file") and fifth ("new-file") arguments will bepassed to the diff tool.

2) Type

$ git config --global diff.external <path_to_wrapper_script>

at the command prompt, replacing with the path to "git-diff-wrapper.sh", so your ~/.gitconfig contains

-->8-(snip)--[diff]    external = <path_to_wrapper_script>--8<-(snap)--

Be sure to use the correct syntax to specify the paths to the wrapper script and difftool, i.e. use forward slashed instead of backslashes. In my case, I have

[diff]    external = c:/Documents and Settings/sschuber/git-diff-wrapper.sh

in .gitconfig and

"d:/Program Files/Beyond Compare 3/BCompare.exe" "$2" "$5" | cat

in the wrapper script. Mind the trailing "cat"!

原來有個更簡單的方法。。。

http://jeetworks.org/node/90

在.gitconfig檔案中添加

  4 [diff]
  5         tool = gvimdiff
  6 [difftool]
  7         prompt = false

然後比如對某一個SHA,要顯示這個SHA的diff

git difftool SHA^...SHA

Thanks <SethRobertson> for this help:)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.