2

I had the file:

~/.gitconfig

working ok, but I decided to move it to:

~/.config/git/config

Now, git config --global -l just gives:

$ git config --global -l
fatal: unable to read config file '/home/user/.gitconfig': No such file or directory

I have $XDG_CONFIG_HOME configured and exported, as well as $HOME. What would be the problem?

Is there some configuration I can set to /etc/gitconfig to make git aware of the new configuration file location (something like core.globalconfig=$HOME/.config/git/config)?

Thanks

--

PS. System: Debian Linux Wheezy

Reference:

git config

DrBeco
  • 11,237
  • 9
  • 59
  • 76
  • Just tried `[core] path = /home/user/.config/git/config` to no avail. – DrBeco Nov 23 '14 at 19:16
  • 1
    Try creating a symlink `~/.gitconfig` that points to `~/.config/git/config`. – jub0bs Nov 23 '14 at 19:18
  • That would also do, Jubobs! Thanks for the tip. – DrBeco Nov 23 '14 at 19:23
  • 1
    For anyone who reads, I'm still hoping there is a better answer than mine bellow. Maybe I need to check if the environment variables is really ok? A better question is: why git is not checking `$HOME/.config/git/config`? – DrBeco Nov 23 '14 at 19:50
  • possible duplicate of [Changing .gitconfig location](http://stackoverflow.com/questions/4050905/changing-gitconfig-location) – jub0bs Nov 23 '14 at 19:55
  • 1
    After reading the question you pointed out, I saw that there is no better solution for windows. For linux, even that X Desktop Group has standard XDG* variables, it looks like git doesn't give a penny. So I'm accepting the answer I research, with no more hopes, unless a next version of GIT changes things. – DrBeco Nov 23 '14 at 20:37

1 Answers1

3

Ok, after reading this question about including files, I came up with this simple solution to make git aware of the configuration file in a different directory:

Add this line to your system file (/etc/gitconfig)

[include]
     path = $HOME/.config/git/config

Command:

sudo git config --system include.path '$HOME/.config/git/config'

And voilá!

-- Edited:

This solution makes git config -l works, but still git config --global -l does not work.

A workaround (from @Jubobs comment) would be create a symbolic link:

ln -s ~/.config/git/config .gitconfig

But that would still leave the .gitconfig file in the $HOME.

There must be a better solution.

Community
  • 1
  • 1
DrBeco
  • 11,237
  • 9
  • 59
  • 76
  • Actually, @Jubobs , your comment is better than my answer. For one: `git config --global -l` still gives error. But `git config -l` now works. – DrBeco Nov 23 '14 at 19:28