# 在不同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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/devops/git/git_mulitple_user_names_for_different_projects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
