经常遇到一个问题, 同一台电脑需要git pull不同账户及仓库的代码,
则需要重新配置name, email等属性
git config --global name "xxx"
git config --global email "yyy"
~/.gitconfig文件中会保存当前的配置。
如何使多用户同时有效呢??
以下是一个方式:
[includeIf "gitdir:~/github_workspace"]
› path = ~/.gitconfig-github
[includeIf "gitdir:~/udisk_workspace"]
› path = ~/.gitconfig-work
[user]
› email = xxx@xxx.com
› name = xxx
[color]
› ui = auto
根据当前目录的不同, 决定使用对应的.gitconfig配置。
[user]
› email = yyy@yyy.com
› name = yyy
[color]
› ui = auto
[core]
editor = vim
[push]
› default = matching
~ [user]
› email = zzz@zzz.com
› name = zzz
[color]
› ui = auto
[core]
editor = vim
[push]
› default = matching