1

Does Git have anything like Hg's HGRCPATH, i.e. an enviromental variable which you can modify to change the location where Hg will search for its global configuration file.

In git that can be somewhat accomplished by changing HOME, but that will affect unknown number of other applications, which is why I'm trying to avoid it.

Ondrej Slinták
  • 31,386
  • 20
  • 94
  • 126
Rook
  • 60,248
  • 49
  • 165
  • 242

1 Answers1

2

There's environmental variable called GIT_CONFIG:

Take the configuration from the given file instead of .git/config. Using the "--global" option forces this to ~/.gitconfig. Using the "--system" option forces this to $(prefix)/etc/gitconfig.

Also check git docs for more information about git configs.

Ondrej Slinták
  • 31,386
  • 20
  • 94
  • 126
  • I've read that on my way over here, but I'm still confused - what would I have to change for it to search for "c:\config_files\.gitconfig" instead of in "c:\docu...and settings\username\.gitconfig"? (but so that I don't have to give the position of it every time I open up a new repo) – Rook Oct 30 '10 at 12:08
  • By default, GIT_CONFIG doesn't exist as environmental variable. You have to set it in Windows and set its value to "/c/some/folder/.gitconfig". You can try if it works by typing "echo $GIT_CONFIG" into Git console. – Ondrej Slinták Oct 30 '10 at 12:44
  • Doesn't work. I created GIT_CONFIG env. var. with a path to my .gitconfig (C:\temp\.gitconfig) and although it echoes that env. variable it stills uses the settings from my old .gitconfig. Working under XP here (but I gather you guessed that by now ...) – Rook Oct 31 '10 at 00:50
  • Do you set those new options with --global parameter? – Ondrej Slinták Oct 31 '10 at 07:43
  • @Ondrej - Uhm, no. I just setted the env. var, moved the file from c:\doc...settings\username\ to c:\temp and edited it, and changed the name in it to see whether something will change. What else do I need to set? I find Git's documentation very confusing for now. – Rook Oct 31 '10 at 20:04
  • This should be all you need to set. Try to change user.email and user.name in your new .gitconfig to something else. Then create new git repo for testing and do some changes so you can commit. Check "git whatchanged" and see if user details in the logs were the same as in your new .gitconfig. – Ondrej Slinták Nov 01 '10 at 12:02