setting tabwidth to 4 in git show / git diff

前端 未结 2 757
礼貌的吻别
礼貌的吻别 2020-12-07 15:43

At work we are several developers and don\'t have a code style guide, and some developers indent with tabs, and some others with 4 spaces (luckily noone of the indent with s

相关标签:
2条回答
  • 2020-12-07 16:21

    I believe git config --global core.pager 'less -x1,5'

    References:

    • Original: (No longer valid) git-scm chp7-1
    • Newer:
      • git-config#git-config-corepager
      • Customizing Git
    0 讨论(0)
  • 2020-12-07 16:21

    As the answer https://stackoverflow.com/a/10584237/1850340 did not work for me because of my color settings I came up with following solution:

    TAB=$'\t' && git config --global core.pager "sed 's/$TAB/    /g' | less" && unset TAB
    

    This replaces all tab characters with 4 spaces before displaying it with less. (The TAB workaround is needed to circumvent the shells backslash escape)

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