git 在 push/push to 時需要使用到 user.name 和 user.email,一般通過git bash 來進(jìn)行配置或修改。
user.name/user.email
// 查看user.name
git config user.name
// 查看user.email
git config user.email
配置user.name/user.email
// 配置user.name
git config --global user.name "your user name"
// 配置user.email
git config --global user.email "your user email"
這里需要注意的是,該命令只能用于初次配置user.name/email,如果不小心配置錯誤,或者重復(fù)配置,不可以通過重復(fù)執(zhí)行以上命令來修改user.name/email,否則可能或報錯說無法重復(fù)配置,或者導(dǎo)致一個key配置了多個value。
修改user.name/user.email
如果想要修改已經(jīng)配置過的user.name或email,有兩種方式,一種是通過git bash來修改;一種是直接修改.gitconfig文件。
1.git bash
// 修改user.name
git config --global --replace-all user.name "your user name"
// 修改user.email
git config --global --replace-all user.email "your user email"
2.修改.gitconfig文件
- 該文件是隱藏文件,位于C:\Users{user}.gitconfig,直接修改里邊的name或者email,如果有重復(fù)的name或email,可以將其刪掉,只剩下一個就好。
- 修改完,通過git bash輸入git config --list可以查看是否修改成功了。