'git ~/.config/git/config not reading

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



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community