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 6650411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:53:24+00:00 2026-05-26T00:53:24+00:00

When I type git diff , I’d like to see a side-by-side diff, like

  • 0

When I type git diff, I’d like to see a side-by-side diff, like with diff -y, or like to display the diff in an interactive diff tool like kdiff3. How can this be done?

  • 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. Editorial Team
    Editorial Team
    2026-05-26T00:53:24+00:00Added an answer on May 26, 2026 at 12:53 am

    Although Git has an internal implementation of diff, you can set up an external tool instead.

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

    1. setting the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.
    2. configuring the external diff tool via git config

    ymattw‘s answer is also pretty neat, using ydiff

    See also:

    • https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
    • git diff --help
    • http://www.pixelbeat.org/programming/diffs/

    When doing a git diff, Git checks both the settings of above environment variables and its .gitconfig file.

    By default, Git passes the following seven arguments to the diff program:

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

    You typically only need the old-file and new-file parameters. Of course most diff tools only take two file names as an argument. This means that you need to write a small wrapper-script, which takes the arguments which Git provides to the script, and hands them on to the external git program of your choice.

    Let’s say you put your wrapper-script under ~/scripts/my_diff.sh:

    #!/bin/bash
    # un-comment one diff tool you'd like to use
    
    # use standard diff command with options: (2023)
    /usr/bin/diff -y "$2" "$5" 
    
    # side-by-side diff with custom options:
    # /usr/bin/sdiff -w200 -l "$2" "$5" 
    
    # using kdiff3 as the side-by-side diff:
    # /usr/bin/kdiff3 "$2" "$5"
    
    # using Meld 
    /usr/bin/meld "$2" "$5"
    
    # using VIM
    # /usr/bin/vim -d "$2" "$5"
    

    you then need to make that script executable:

    chmod a+x ~/scripts/my_diff.sh
    

    you then need to tell Git how and where to find your custom diff wrapper script.
    You have three choices how to do that: (I prefer editing the .gitconfig file)

    1. Using GIT_EXTERNAL_DIFF, GIT_DIFF_OPTS

      e.g. in your .bashrc or .bash_profile file you can set:

       GIT_EXTERNAL_DIFF=$HOME/scripts/my_diff.sh
       export GIT_EXTERNAL_DIFF
      
    2. Using git config

      use "git config" to define where your wrapper script can be found:

       git config --global diff.external ~/scripts/my_diff.sh
      
    3. Editing your ~/.gitconfig file

      you can edit your ~/.gitconfig file to add these lines:

       [diff]
         external = ~/scripts/my_diff.sh
      

    Note:

    Similarly to installing your custom diff tool, you can also install a custom merge-tool, which could be a visual merging tool to better help visualizing the merge. (see the progit.org page)

    See: http://fredpalma.com/518/visual-diff-and-merge-tool/ and https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I type git diff , I want to view the output with my
Consider type like this one public interface IHaveGenericMethod { T1 Method<T1>(T1 parm); T2 Method<T1,T2>(T1
When I type: git push heroku master, this is what happens $:sample_app git push
When I'm on master, I only have to type 'git push' to push commits
I've got vim setup as my external diff tool: [diff] external = git_diff_wrapper #!/bin/sh
Right now, when I type git branch it lists my branches in an arbitrary
Some repository clones I have allow me to do this: % git pull %
I added the following line to .gitignore : sites/default/settings.php but when I type git
my ~/.gitconfig is: [alias] commit = !sh commit.sh However, when I type git commit
I'm writing a script to run things like git status in each of the

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

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.