更改大量 git 提交消息
显然,我很久以前在设置 git 时就输错了我的电子邮件,因此我的电子邮件在许多存储库中都是不正确的(我输入了 0
而不是 o
)。我签署了所有提交,因此多年来,在每个存储库中的几乎每个提交中,都表示 签署人为: <[电子邮件受保护]>
而不是 签署者:[电子邮件受保护]>
。现在我不能只切换我的电子邮件,所以我想切换这些提交消息。
我已经完成了 git config --global user.email "[email] protected]",所以这在将来应该不会成为问题。
首先,是否有可能在不把事情搞砸的情况下大规模地改变信息?我已经将这些更改推送到多个服务器,其他服务器也已拉取这些更改。
其次,有没有办法可以在脚本中快速完成此操作?即:
foreach(commit in log)
{
change "<[email protected]>" to "<[email protected]>"
}
感谢所有帮助,谢谢!
Apparently I mistyped my email a long time ago, whenever I was setting up git, and so my email has been incorrect in many repositories (I typed a 0
instead of an o
). I sign all of my commits, so in almost every commit in every repo for years it's said signed off by: <[email protected]>
instead of signed off by: <[email protected]>
. Now I can't just switch my email, so I would like to switch these commit messages.
I've already done the git config --global user.email "[email protected]"
, so this shouldn't be a problem in the future.
Firstly, is it possible to change the messages on this large of a scale without royally messing things up? I've already pushed these changes to multiple servers and others have pulled those changes.
Second, is there a way I could do this quickly in a script? ie:
foreach(commit in log)
{
change "<[email protected]>" to "<[email protected]>"
}
All help is appreciated, and thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果变更集已经公开并且其他人已拉取它们,那么您不应该碰它们。修改它们将改变它们的 SHA,这将给其他人带来巨大的麻烦(请参阅
git rebase
页)。既然我已经提到了这一点,假设它们还没有公开。如果是这种情况,您想要用来修改它们的工具将是 <代码>git过滤器分支。
If the changesets have already been made public and others have pulled them, then you should not touch them. Modifying them will change their SHAs, which will screw things up for others on a royal scale (see the "Recovering from Upstream Rebase" section on the
git rebase
page).Now that I've mentioned that, suppose hypothetically they hadn't been made public. If that were the case, the tool you'd want to use to modify them all would be
git filter-branch
.