2

Centos 6, Git 2.0.4

Setting up git on a server for another developer, as system root I did:

root@server $ git config --global user.name "My Dev Guy"
root@server $ su mydevguy
mydevguy@server $ git config --list

No user was set! So, as system user "mydevguy" I did:

mydevguy@server $ git config --global user.name "Some Other Guy"
mydevguy@server $ git config --list

Shows "Some Other Guy" as the user name, as expected. So I exit back to system root user and see what's there.

mydevguy@server $ exit
root@server $ git config --list

And it still shows "My Dev Guy" there.

I thought these were global git settings, but it seems to be possible to configure git users per system users. Is that so? Where can I read more about this?

Buttle Butkus
  • 9,206
  • 13
  • 79
  • 120
  • 2
    I think you may be looking for `git config --system`? – Joachim Isaksson Jan 27 '16 at 06:06
  • I wasn't really "looking" for anything, but you have helped me find it. This is awesome because everything else I found seemed to say you couldn't have more than one git user working on the same machine, which seemed absurd. E.g. http://stackoverflow.com/questions/3860112/multiple-github-accounts-on-the-same-computer – Buttle Butkus Jan 27 '16 at 06:15
  • check the options [--global, --system, and --local](https://www.kernel.org/pub/software/scm/git/docs/git-config.html) in the manpage. These options clearly specify which configuration files are affected. – user3159253 Jan 27 '16 at 06:16

1 Answers1

3

When reading, the values are read from the system, global and repository local configuration files by default, and options --system, --global, --local and --file <filename> can be used to tell the command to read from only that location

The different locations mean;

--local Use the repository .git/config file (per repository)
--global Use the global ~/.gitconfig file (per user)
--system Use the system-wide $(prefix)/etc/gitconfig (per system)

--local is the default for writing, for reading the default is to read all the files.

Reference.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294