3

Is there a way to run git commands without using the default gitconfig?

For example, say I had setup a custom diff tool in my gitconfig. If I wanted to use the default git diff (which uses diff?), how would I do it?

Thanks!

2

Use the --ext-diff option with git diff. --ext-diff allows you to specify a different external diff tool.

4

To ignore the system Git config (/etc/gitconfig), set the environment variable GIT_CONFIG_NOSYSTEM to 1 (or true or yes). To ignore the global Git config (~/.gitconfig), set the environment variable GIT_CONFIG_NOGLOBAL to 1 (or true or yes).

Example: GIT_CONFIG_NOGLOBAL=1 git diff

These options are available since ab88c36 (allow suppressing of global and system config, 2008-02-06). The first release (candidate) that appears to know them is 1.5.5-rc0 (git describe --contains ab88c36).

1
  • 5
    This was removed in 2011 but HOME= git diff will prevent Git from reading $HOME/.gitconfig, accomplishing the same thing (tested in Git v2.3.2). May 6 '15 at 1:49
0

Use GIT_CONFIG_NOGLOBAL=1 HOME= XDG_CONFIG_HOME= git diff to ensure that no outside configuration at all is read by git.

From the official documentation:

GIT_CONFIG_NOSYSTEM

Whether to skip reading settings from the system-wide $(prefix)/etc/gitconfig file. This environment variable can be used along with $HOME and $XDG_CONFIG_HOME to create a predictable environment for a picky script, or you can set it temporarily to avoid using a buggy /etc/gitconfig file while waiting for someone with sufficient permissions to fix it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.