Is it possible to have all “git diff” commands use the “Python diff”, in all git projects?

When including the line

*.py diff=python

in a local .gitattributes file, git diff produces nice labels for the different diff hunks of Python files (with the name of the function where the changes are, etc.).

  • Getting Git GUI to Ignore Space Changes in its diff View
  • is there a simple way to know which files will be updated in the next 'git pull'?
  • IntelliJ Diff Tool in SourceTree
  • Check diff against file on the server
  • Mercurial diff not working after move/rename
  • Using Visual Studio 2012's built-in merge tool with Git
  • Is is possible to ask git to use this diff mode for all Python files across all git projects? I tried to set a global ~/.gitattributes, but it is not used by local git repositories. Is there a more convenient method than initializing each new git project with a ln -s ~/.gitattributes?

  • What's the -practical- difference between a Bare and non-Bare repository?
  • git push to nginx+git-http-backend : error: Cannot access URL http return code 22 fatal: git-http-push failed
  • Using someone else's repo as a Git Submodule on GitHub
  • Using editorconfig within Git submodules
  • How can I corrupt a Git repository?
  • git push error: pack-objects died with strange error
  • 3 Solutions collect form web for “Is it possible to have all “git diff” commands use the “Python diff”, in all git projects?”

    Quoting from gitattributes(5):

    Attributes that should affect all repositories for a single user should be placed in a file specified by the core.attributesfile configuration option (see git-config(1)). Its default value is $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/attributes is used instead. Attributes for all users on a system should be placed in the $(prefix)/etc/gitattributes file.

    To tell git to use ~/.gitattributes you need to put this in ~/.gitconfig:

      attributesfile = ~/.gitattributes

    No, git only looks for attributes locally: .gitattributes and .git/info/attributes

    Git Baby is a git and github fan, let's start git clone.