转自:[https://blog.csdn.net/u013719138/article/details/89888908](https://blog.csdn.net/u013719138/article/details/89888908) # 一、正文 ## 查看 git 所有配置 ```bash git config --list ``` ## 查看当前项目配置的 git 用户 在项目目录下输入 ```bash git config user.name // 当前项目 git 用户名 git config user.email // 当前项目 git 用户邮箱 ``` ## 设置当前项目的 git 用户 在项目目录下输入 ```bash git config user.name myName // 自己的用户名 git config user.email myEmail // 自己的邮箱 git config --list // 查看当前项目的 git 配置信息(会先列出全局配置,最下面列出的是当前项目的配置) ``` 在当前项目下面查看的配置是全局配置 + 当前项目的配置, 使用的时候会优先使用当前项目的配置。 也可以直接在项目的根目录里的 `.git` 文件夹里,打开 `config` 文件查看当前项目的 git 配置信息: ```bash [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [submodule] active = . [remote "origin"] url = https://github.com/DawnYu9/Test.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master ``` 在最后面添加该项目的用户信息: ```bash [user] name = myName email = myEmail ``` ## 设置全局的 git 用户 ```bash git config --global user.name globalName // 全局的用户名 git config --global user.email globalEmail // 全局的邮箱 git config --list // 查看配置信息 ``` # 二、参考 - [Git 设置全局或者当前项目的用户信息](https://blog.csdn.net/u013719138/article/details/89888908)