git在push/push to時需要使用到user.name和user.email,切記一定要現配置好
查看user.name/user.email
git config user.name git config user.email
查看所有配置信息
git config --list
配置user.name/user.email
git config user.name "newName" git config user.email "newEmail"
加上--global可以全局修改,否則僅在本git-repo生效。
配置全局user.name/user.email
git config --global user.name "your user name" git config --global user.email "your user email"
這里需要注意的是,該命令只能用於初次配置user.name/email,如果不小心配置錯誤,或者重復配置,不可以通過重復執行以上命令來修改user.name/email,否則可能或報錯說無法重復配置,或者導致一個key配置了多個value。
修改user.name/user.email
如果想要修改已經配置過的user.name或email,有兩種方式,一種是通過git bash來修改;一種是直接修改.gitconfig文件。
1. git bash
git config --global --replace-all user.name "your user name" git config --global --replace-all user.email"your user email"
2. 修改.gitconfig文件
該文件是隱藏文件,位於C:\Users\{user}\.gitconfig,直接修改里邊的name或者email,如果有重復的name或email,可以將其刪掉,只剩下一個就好。
修改完,通過git bash輸入git config –list可以查看是否修改成功了。
修改最近一次commit的user.name/user.email
git commit --amend --author="userName <userEmail>"
注意不能缺少< >
此指令僅能更新最近的一次commit的用戶名郵箱