> For the complete documentation index, see [llms.txt](https://huataihuang.gitbook.io/cloud-atlas-draft/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://huataihuang.gitbook.io/cloud-atlas-draft/devops/git/git_mulitple_user_names_for_different_projects.md).

# 在不同git仓库代码使用不同用户名

通常在使用github时候，指导手册都假设你只使用github仓库，所以会指导你使用全局git配置来设置提交都用户名和电子邮件:

```
git config --global user.name myname
git config --global user.email myname@mydomain.com
```

实际上这个配置会记录在用户目录下的 `~/.gitconfig1` 的内容如下:

```
[user]
    name = myname
    email = myname@mydomain.com
```

但是，有些仓库可能需要使用不同的账号名字来提交，则使用 `--local` 配置:

```
git config --local user.name myname_special
git config --local user.email myname_special@mydomain.com
```

此时会修改代码库的 `.git/config` 配置，独立添加本仓库的配置

```
[user]
    name = myname_special
    email = myname_special@mydomain.com
```

## 参考

* [git multiple user names for the different projects within the same system](https://stackoverflow.com/questions/9063176/git-multiple-user-names-for-the-different-projects-within-the-same-system)
