git 为不同的项目设置不同的用户名和邮箱

1,找到项目所在目录下的 .git/文件夹,进入.git/文件夹,然后执行如下命令分别设置用户名和邮箱:

git config user.name "moonlight"
git config user.email "[email protected]"

然后执行命令查看config文件:cat config

发现里面多了刚才配置的用户名和邮箱信息,即成功为该项目单独设置了用户名和邮箱

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
[remote "origin"]
	url = https://github.com/552277/calendar.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
[user]
	name = moonlight
	email = [email protected]

2,如果为所有项目设置默认的用户名和邮箱,则执行如下命令(即多了"--global"修饰,添加为全局变量):

git config --global user.name"moonlight"
git config --global user.email"[email protected]"

猜你喜欢

转载自blog.csdn.net/qq_2300688967/article/details/81094140