Search code examples
gitmacosgit-config

Apple M2, ~/.gitconfig file fails on running source ~/.gitconfig


I am trying to add some values to ~/.gitconfig file. After i add it, on running source ~/.gitconfig i see that file is not getting parsed. It says:

source ~/.gitconfig 
/Users/myuser/.gitconfig:1: no matches found: [user]

contents of gitconfig:

[user]
  email = [email protected]
  name = testuser

I think the properties are stored in some other file. Does anyone know what file is it?


Solution

  • source is a shell command, that causes the shell to read commands from a file and execute them. However, .gitconfig does not contain shell commands, so source:ing it makes no sense at all.

    You should not have to do anything at all to make changes to Git’s config files take effect. Since Git rereads the config files each time you run a Git command, everything should just work. (Shell config files are different – the shell reads them every time it starts, but the shell does not start very often, which is why you need to source them to make changes take effect in an already-running shell.)