我正在使用GitHub客户端和Atlassian的sourcetree。我想为每个软件使用两个不同的全局git配置。
目前,我必须编辑和检查每次提交我的作者和电子邮件名称。
那么,我该如何为我使用的每个git程序指定唯一的配置呢?
此致敬礼。
目前,我必须编辑和检查每次提交我的作者和电子邮件名称。
那么,我该如何为我使用的每个git程序指定唯一的配置呢?
此致敬礼。
git config user.name xxxx
git config user.email yyyy
--global
选项。我受到了SzG的答案的启发。这是我的最终解决方案:
首先查看全局git配置。您可以在主目录中找到.gitconfig
文件(在Windows上:%userprofile%\.gitconfig
,在Linux上:~/.gitconfig
)。
我在全局git配置文件目录中创建了2个批处理文件。
GitHub.bat和SourceTree.bat
GitHub.bat
@echo off
cd /D %userprofile%
del .gitconfig
copy GitHub.bat .gitconfig
GitHub
[user]
name = Name1
email = email1@example.com
[core]
autocrlf = true
excludesfile = C:\\Users\\{windowsusername}\\Documents\\gitignore_global.txt
SourceTree.bat
@echo off
cd /D %userprofile%
del .gitconfig
copy SourceTree.bat .gitconfig
SourceTree
[user]
name = Name2
email = email2@example.com
[core]
autocrlf = true
excludesfile = C:\\Users\\{windowsusername}\\Documents\\gitignore_global.txt
所以这个工作正常,只需要在提交之前运行其中一个批处理程序,我就可以使用两个不同的作者名称和不同的电子邮件。