git 修改用户名,用户邮箱

339 阅读1分钟

用户名,邮箱一般设置在--global(全局作用域)下,但是有时候只需要改变部分仓库的用户名和邮箱,这时候可以用到--local(当前项目),--worktree(当前工作树)

查看用户名,邮箱

git config --get user.name
git config --get user.email

设置或修改全局用户名,邮箱

git config --global use.name '你的名字'
git config --global use.email '你的邮箱'

打开编辑器编辑,用法同vim

git config -e --global
[user]
        email = qxnote@163.com
        name = qx
[i18n]
        commitencoding = utf-8
        logoutputencoding = utf-8
[difftool "sourcetree"]
        cmd = '' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
        cmd = "'' "
        trustExitCode = true
[core]
        autocrlf = input