Note that this blog post has been archived. Information may be out of date or incorrect.

Setting the Tab Width for the git-diff command

I usually work with a tab width of 4 when editing code, but git-diff (that is the *nix less program) seems to use a default tab width of 8. You can change this behavior by setting the core.pager option to something like this:

less -x4

This would result in a tab width of 4. If you are not familiar with git config, here’s how you set the option:

$ git config --global core.pager 'less -x4'

If you remove the --global flag, the option will be changed only for the current git repository, otherwise it will be changed globally for the current user account.