Git,重写以前的提交用户名和电子邮件 [英] Git, rewrite previous commit usernames and emails

查看:140
本文介绍了Git,重写以前的提交用户名和电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Github上提交了一大堆提交项目,但是我意识到我没有在我目前使用的计算机上设置正确的电子邮件和提交者全名来提交我的提交,因此用户头像和电子邮件地址不存在。

I've committed a bunch of commits to a project on Github, however I realized I hadn't set up the proper email and committer full name on the computer I'm currently using to make my commits and therefore the users avatar and email address are not there.

如何重写所有过去提交的电子邮件地址和用户名?

How can I rewrite all past commit email and usernames?

推荐答案

您可以使用此别名,因此您可以执行:

You can use this alias so you can do:

git change-commits GIT_AUTHOR_NAME "old name" "new name"

或最近10次提交:

or for the last 10 commits:

git change-commits GIT_AUTHOR_EMAIL "old@email.com" "new@email.com" HEAD~10..HEAD

别名:

Alias:

change-commits = "!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [[ \\\"$`echo $VAR`\\\" = '$OLD' ]]; then export $VAR='$NEW'; fi\" $@; }; f "

来源: https://github.com/brauliobo/gitconfig/blob/master/configs/.gitconfig

希望它有用。

这篇关于Git,重写以前的提交用户名和电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆