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

  • Home
  • SEARCH
  • 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 6624667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:40:53+00:00 2026-05-25T21:40:53+00:00

I would like to have git diff outputs me regular diffs for all files,

  • 0

I would like to have git diff outputs me regular diffs for all files, except *.tex. For *.tex files, I would like to see the output of git diff --word-diff.

I was playing around with .gitattributes and .gitconfig, but the furthest I got was to get a partial display for one .tex file, followed by a crash.

Is it possible to get this behaviour?

My .gitattributes:

*.tex diff=latex

.gitconfig:

[diff "latex"]
    wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"
    command = ~/bin/word-diff.sh

and word-diff.sh:

#!/bin/sh 
git --no-pager diff --color-words "$2" "$5"
  • 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-25T21:40:54+00:00Added an answer on May 25, 2026 at 9:40 pm

    Can you post (or link to) a complete example? I’ve set up exactly what you’ve described and it seems to work fine. That is, the diff output highlights words rather than lines, and all of the changes I made were included (that is, it didn’t crap out early or anything). The only anomaly was that diff would always exit with:

    external diff died, stopping at foo.tex.
    

    This happens because git diff, when run in the manner in which you’re using it, behaves like the standalone diff tool: it exits with a nonzero exit code if the files differ. Git doesn’t expect this behavior; it assumes that your custom command will always execute successfully and that error exit codes indicate an actual problem.

    Git already knows that the files are difference and does not require the external command to make this determination. The external command is strictly a formatting tool.

    If you modify your diff-words.sh script to always exit successfully, things should work out better:

    #!/bin/sh
    git --no-pager diff --color-words "$2" "$5"
    exit 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather large diff of 2 GIT branches and would like to
I would like to have a git repository that consists mainly of binary files.
I have a project A that is a Git repository. I would like to
I would like to have all developers on my team to use the same
I have a Git repository with few branches and dangling commits. I would like
Essentially I would like a list of all modified files so I can export
I have a patch file (unified diff), like the output from svn diff ,
I have git repository A and git repository B, and I would like to
I have a problem that I would like have solved via a SQL query.
I would like to have a reference for the pros and cons of using

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.