git修改用户名密码(git设置本地用户名和邮箱)
开发需要,本地维护了多个用户名和邮箱组合,今天提交代码后,发现用户名和邮箱错了,由于是贡献的开源代码,必须改回来。
修改当前repo的用户名和邮箱
git config user.name "example"git config user.email "example@163.com"
修改全局的用户名和邮箱
git config --global user.name "example"git config --global user.email "example@163.com"
修改最近一次提交记录的用户名和邮箱
git commit --amend --author="userName <userEmail>"
修改历史提交的用户名和邮箱
git filter-branch –env-filter ‘
if [ “GIT_AUTHOR_NAME” = “oldName” ]
then
export GIT_AUTHOR_NAME=”newName”
export GIT_AUTHOR_EMAIL=”newEmail”
fi ‘ HEAD~3..HEAD
git filter-branch –env-filter ‘
if [ “GIT_COMMITTER_NAME” = “oldName” ]
then
export GIT_COMMITTER_NAME=”newName”
export GIT_COMMITTER_EMAIL=”newEmail”
fi ‘ HEAD~3..HEAD
如果提示:
Cannot create a new backup.A previous backup already exists in refs/original/Force overwriting the backup with -f
可以加上-f,即git filter-branch -f –env-filter。
本文内容由互联网用户自发贡献,该文观点仅代表作者本人。如发现本站有涉嫌抄袭侵权/违法违规的内容,请发送邮件至 203304862@qq.com
本文链接:https://www.jinnalai.com/fenxiang/84103.html