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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:09:14+00:00 2026-05-28T15:09:14+00:00

Is it possible to configure Git to use my configured difftool with git add

  • 0

Is it possible to configure Git to use my configured difftool with git add --patch?

I would like to pick the changes to add to the index via my own difftool.

  • 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-28T15:09:15+00:00Added an answer on May 28, 2026 at 3:09 pm

    No, unfortunately.

    I suppose I can see that working – Git generates a temporary file based on what’s currently in the index, hands it to the difftool along with a copy of the current work tree version (to protect you from making further changes), lets you use the difftool to move some of the changes to the index version, then once you save and quit, stages whatever content is in that modified index version. Note that this would require the difftool to also be a bit of an editor, and not all valid difftools are; some of them are just for viewing diffs. Note also that this is basically bypassing all of git add -p. You wouldn’t have any of the normal interface from it for moving between hunks, splitting hunks, and so on. The difftool would be entirely responsible for all of that.

    If your difftool is fully-featured enough to do this sort of thing, then I suppose you could write a script to do it. An outline, without really any error protection, handling of special cases (binary files?), and completely untested:

    #!/bin/bash
    tmpdir=$(mktemp -d)
    git diff --name-only |
    while read file; do
        cp "$file" $tmpdir
        # this has your changes in it
        work_tree_version="$tmpdir/$file"
        # this has the pristine version
        index_version=$(git checkout-index --temp "$file")
        # and now you bring changes from the work tree version into the index version,
        # within the difftool, and save the index version and quit when done
        my_difftool "$work_tree_version" "$index_version"
    
        # swap files around to run git add
        mv "$file" "$work_tree_version"
        mv "$index_version" "$file"
        git add "$file"
        mv "$work_tree_version" "$file"
        # you could also do this by calculating the diff and applying it directly to the index
        # git diff --no-index -- "$file" "$original_index_version" | git apply --cached
    
    rm -r $tmpdir
    

    Probably a lot of ways to improve that; sorry I don’t have time to be careful and thorough with it right now.

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

Sidebar

Related Questions

Is it possible to configure git diff to use emacs diff? If yes, can
Is it possible to configure a WCF service to use sessions, and also not
I have a project hosted on git.debian.org (alioth) and I'd like to configure a
Is it possible to configure the Windows Workflow SqlWorkflowPersistanceService to use different SQL Server
It seems like it should be possible to configure Visual Studio to print out
Is this possible to configure IIS7 to achieve the same functionality like Apache has
I am using git's default post-receive-email hook. Is it possible to configure the script
Is it possible create/configure MySQL for functionality like SQL Server's Linked Server? If yes,
Is it possible to configure vim to follow symlinks via gf ? For example,
Is it possible to configure Hibernate to use a javax.sql.DataSource instance? My application already

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.