David Reynolds David Reynolds - 1 year ago 68
Git Question

Is it possible to include a file in your .gitconfig

I'd like to include a file in my .gitconfig that has my github settings - is this possible?

Can I do something like this:

include = /path/to/file

Answer Source

Git (1.7.10+) now supports this syntax in .gitconfig:

    path = /path/to/file

See here for a detailed description of the git change and its edge cases.

By the way, a couple of subtleties worth pointing out:

  1. Environment-variable expansion, e.g. $HOME, is not supported. (Expansion of ~ appeared in Git

  2. If a relative path is specified, then it is relative to the .gitconfig file that has the [include] statement. This works correctly even across chained includes -- e.g. ~/.gitconfig can have:

        path = subdir/gitconfig

    and subdir/gitconfig can have:

        path = nested_subdir/gitconfig

    ... which will cause subdir/nested_subdir/gitconfig to be loaded.

  3. If git can't find the target file, it silently ignores the error. This appears to be by design.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download