Posts Git override global email and name for a project
Post
Cancel

Git override global email and name for a project

In order avoid using global email address and user name for a specific project.

We can override them for a specific project by using the below commands.

These local settings are present in any project .git/config file and are used to override git global configs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
$ mkdir test
$ cd test
$ git init
Initialized empty Git repository in /home/pc/test/.git/

$ # now let's view current local config values
$ git config --local --list
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true

$ # now let us add email address to this config
$ git config --local --add user.email test@testemail.com

$ # now let us view the config again
$ git config --local --list
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
[email protected]

$ # now let us add user.name
$ git config --local --add user.name rahul

$ # now let us view the config again
$ git config --local --list
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
[email protected]
user.name=rahul

$ # to view that all this information is infact written to current project .git/config
$ cat .git/config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[user]
	email = [email protected]
	name = rahul
This post is licensed under CC BY 4.0 by the author.