I use tabs for indentation in my python programs, but I would like to collaborate (using git) with people who use spaces instead.
Is there a way for git to automatic
Yes, one potential solution is to use a git attribute filter driver (see also GitPro book), to define a smudge/clean mechanism.
That way:
You can declare this filter driver (named here 'tabspace
') in the .git/info/attributes
(for a filter applied to all files within the Git repo), with the following content:
*.py filter=tabspace
Now run the commands:
# local config for the current repo
git config filter.tabspace.smudge 'script_to_make_tabs'
git config filter.tabspace.clean 'script_to_make_spaces'
See Olivier's answer for a concrete working example of such a smudge/clean set of instructions.