Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 63693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:40:21+00:00 2026-05-10T18:40:21+00:00

When I type git diff , I want to view the output with my

  • 0

When I type git diff, I want to view the output with my visual diff tool of choice (SourceGear ‘diffmerge’ on Windows). How do I configure git to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:40:22+00:00Added an answer on May 10, 2026 at 6:40 pm

    Since Git1.6.3, you can use the git difftool script: see my answer below.


    May be this article will help you. Here are the best parts:

    There are two different ways to specify an external diff tool.

    The first is the method you used, by setting the GIT_EXTERNAL_DIFF variable. However, the variable is supposed to point to the full path of the executable. Moreover, the executable specified by GIT_EXTERNAL_DIFF will be called with a fixed set of 7 arguments:

    path old-file old-hex old-mode new-file new-hex new-mode 

    As most diff tools will require a different order (and only some) of the arguments, you will most likely have to specify a wrapper script instead, which in turn calls the real diff tool.

    The second method, which I prefer, is to configure the external diff tool via ‘git config’. Here is 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 be passed 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 diff tool, 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’!

    (I suppose the ‘| cat‘ is needed only for some programs which may not return a proper or consistent return status. You might want to try without the trailing cat if your diff tool has explicit return status)

    (Diomidis Spinellis adds in the comments:

    The cat command is required, because diff(1), by default exits with an error code if the files differ.
    Git expects the external diff program to exit with an error code only if an actual error occurred, e.g. if it run out of memory.
    By piping the output of git to cat the non-zero error code is masked.
    More efficiently, the program could just run exit with and argument of 0.)


    That (the article quoted above) is the theory for external tool defined through config file (not through environment variable).
    In practice (still for config file definition of external tool), you can refer to:

    • How do I setup DiffMerge with msysgit / gitk? which illustrates the concrete settings of DiffMerge and WinMerge for MsysGit and gitk
    • How can I set up an editor to work with Git on Windows? for the definition of Notepad++ as an external editor.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 57k
  • Answers 57k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Something like this to send all changes to STDERR: perl… May 11, 2026 at 8:26 am
  • added an answer Use cssFloat as in... element.style.cssFloat = 'value'; That works in… May 11, 2026 at 8:26 am
  • added an answer From http://www.symbian.com/developer/techlib/v9.1docs/doc_source/reference/N10352/UserPanics.html: This panic is raised by the Free() and… May 11, 2026 at 8:26 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

MEILI PLUGIN ACTIVE

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.