8

I am working with 2 projects in same time. One is for my work and another is my personal project. I'd like to use git as version control software.

I have configured .gitconfig under my my directory as follows.

  1 [user]
  2   name = gladder
  3   email = gladder

So git can pickup my user settings automatically. however, I am just wondering that is it possible to get this setting in small scope?

So the project's user settings can override global user settings.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Grace Ladder
  • 101
  • 2
  • 3
  • See also [Can I specify multiple users for myself in .gitconfig?](http://stackoverflow.com/questions/4220416/can-i-specify-multiple-users-for-myself-in-gitconfig). –  May 19 '14 at 01:45

2 Answers2

5

Yes, all the settings that are in $HOME/.gitconfig can be put into .git/config inside each repository.

araqnid
  • 127,052
  • 24
  • 157
  • 134
5

You can use the --file flag with git config (or not as it is the default):

git config --file user.name gladder
git config --file user.email gladder

which will create/set the value in project/.git/config (as araqnid said)

Refer to git-config for more information.

Antoine Pelisse
  • 12,871
  • 4
  • 34
  • 34
  • 2
    Doesn't work on all versions of git `git version 1.8.3.4 (Apple Git-47)` gives error 'key does not contain a section' – spuder Jan 15 '14 at 20:10
  • `git config --file .git/config user.name gladder` or `git config --local user.name gladder` both update .git/config for me – Stan Kurdziel Aug 04 '15 at 15:16