How should I use git diff for long lines?

后端 未结 15 2421
庸人自扰
庸人自扰 2020-12-04 05:37

I\'m running git-diff on a file, but the change is at the end of a long line.

If I use cursor keys to move right, it loses colour-coding—and worse the lines do

相关标签:
15条回答
  • 2020-12-04 06:08

    Noone pointed out this till now. Its quite simple to remember and no extra configuration needs to be done in the git config

    git diff --color | less -R
    
    0 讨论(0)
  • 2020-12-04 06:08

    list the current/default config:

      $ git config --global core.pager  
        less -FXRS -x2
    

    then update and leave out the -S like:

      $ git config --global core.pager 'less -FXR -x2'
    

    the -S: Causes lines longer than the screen width to be chopped rather than folded.

    0 讨论(0)
  • 2020-12-04 06:11

    When you are using "git diff" and it's showing several pages(you see ":" at the end of the page)in this case you can type "-S" and press enter.(S should be capital). it will toggle fold long lines.

    0 讨论(0)
提交回复
热议问题