Git 修改已提交 commit 的作者信息

当Git提交的作者信息错误时,可以使用Git官方指南的方法来修改已提交的commit作者信息。这涉及到重写仓库历史,操作需谨慎,包括创建裸仓库克隆、替换脚本中的变量、运行脚本、校对历史、推送更改和清理临时克隆。
摘要由CSDN通过智能技术生成

问题:

在不同电脑之间不同的 git 邮箱账号,结果 commit 的时候忘记修改配置导致 commit 的名称和邮箱不对

解决方法:

修改Git配置

查看配置:

$ git config user.name
$ git config user.email

修改配置:

$ git config --global user.name "name"
$ git config --global user.email "email"

但是此方法只能补救以后的commit起效,如果想修改之前的作者信息,Github 给出了官方指南:Changing author info

 

修复git历史提交信息

To change the name and/or email address recorded in existing commits, you must rewrite the entire history of your Git repository.

为了修改 commit 的作者邮箱地址,你必须重写整个 git 仓库历史

Warning: This action is destructive to your repository's history. If you're collaborating on a repository with others, it's considered bad practice to rewrite published history. You should only

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值