Git uses a username to associate commits with an identity. The Git username is not the same as your GitHub username.
You can change the name that is associated with your Git commits using the git config
command. The new name you set will be visible in any future commits you push to GitHub from the command line. If you'd like to keep your real name private, you can use any text as your Git username.
Changing the name associated with your Git commits using git config
will only affect future commits and will not change the name used for past commits.
Setting your Git username for every repository on your computer
- Open Git Bash.
Set a Git username:
$ git config --global user.name "Mona Lisa" $ git config --global user.email “xxx@email.com”
Confirm that you have set the Git username correctly:
$ git config --global user.name > Mona Lisa $ git config --global user.email > xxx@email.com
Setting your Git username for a single repository
- Open Git Bash.
- Change the current working directory to the local repository where you want to configure the name that is associated with your Git commits.
Set a Git username:
$ git config user.name "Mona Lisa"
Confirm that you have set the Git username correctly:
$ git config user.name > Mona Lisa $ git config user.email > xxx@email.com
修改你的用户名和邮箱
查看配置
git config --list
git config --global --replace-all user.name “你的用户名”
git config --global --replace-all user.email “你的邮箱”
原文地址:https://docs.github.com/en/get-started/getting-started-with-git/setting-your-username-in-git#