If you are working on projects with different tabstop settings—different than you setting tabs using tabs -n for terminal—you may need to adjust your core.pager by repository or globally. I prefer to do it by repository since every project is different.

Whatever the route you choose, you edit the configuration or issue a git-config command:

[core]
  pager = less -x 5,9

You may already have the pager as cat or less -F -X for direct output. If so, just pipe to less -x 5,9 for paging; to expand -t4 still for direct output; and you will be good.

In this case, the tabstop is 4; for 8, you use 5,13. But you probably don’t need that since 8 is a very common default tabstop.

5,9 means the tabstop starts at 5, then 9, 13, 17, …. If you don’t set the first one to be 5, the diff output with tabs may be skewed.

Just a side note, if you use Pygments to colorize diff output, pygmentize -l diff -O tabsize=4 could be something you need, or

git diff | pygmentize -l diff | less -x 5,9

This need for such setting reminds me of why I like Python, more specifically, the space. There are a lot of people hating Python’s space, but when you have projects all have their own settings, and you can’t find the correct tabstop, it’s a guessing game.

A space is a space, no second interpretation can ever be by user or program.