How to configure git-diff so that long line not wrap around?

I sometimes have long line of code in git repo (e.g. a json config file), and git diff will generate output like below.

long line

  • Git diff tool on every commit?
  • How can I view the output of `git show` in a diff viewer like meld, kdiff3, etc
  • Git Diff between HEAD and SVN Master
  • git patches won't apply
  • How do I exclude certain files from a svn diff?
  • How to tell `git log --stat` to count empty lines
  • On an EC2 instance, I git diff doesn’t wrap the content to the next line, generating following output (I can use left/right keys to navigate), which I personally prefer.

    short line

    Does any one know how I can config the git-diff to change from one behavior to another?

  • Ignore all files with the same name in git
  • Can't push on heroku
  • How do I make separate Gitweb “pages” for each one of my users?
  • How to make a Git merge operation ignore identical changes made to both branches?
  • Is it possible and how “Giving credit for a change” for Mercurial/Git as in Bazaar?
  • Git status shows files as changed even though contents are the same
  • 2 Solutions collect form web for “How to configure git-diff so that long line not wrap around?”

    It’s your terminal or pager program that wraps the lines, not git diff. Try redirecting the output of git diff into a file and open it with an editor that allows to control wrapping – you will see that the lines are not actually wrapped.

    You can try this:

    git diff|cut -c -$COLUMNS
    

    Note however that it will disable colors and paging.

    Thank to torek’s inline response above. Based on that, I realized I can do git diff | less -S to achieve what I want. It does better than the cut -c -$COLUMNS solution because it doesn’t lose any context (I can still use left and right button to view all differences).

    Git Baby is a git and github fan, let's start git clone.