如何使用过滤器分支更改多个提交的提交作者? [英] How to change commit author for multiple commits using filter branch?

查看:61
本文介绍了如何使用过滤器分支更改多个提交的提交作者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用在此链接中找到的脚本进行编辑所有提交中的作者信息.

#!/bin/sh

git filter-branch --env-filter '

OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

但是,我收到以下错误(警告?):

Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f

我也检查了日志.作者信息未更改.我在这里做错了什么?

更新:如 @elpiekay 所述,-f标志构成了脚本工作.

但是任何人都可以解释错误日志本身吗?为什么提到备份?我以前从未做过任何备份(不确定错误日志中将引用哪个备份)

解决方案

实际上,更好的做法是:

您可以立即使用其可能的后继产品: newren/git-filter-repo (在Python中)及其 git shortlog映射作者部分. >

I am using this script found at this link to edit author info across all commits.

#!/bin/sh

git filter-branch --env-filter '

OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

However, I am getting the following error(warning?):

Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f

I checked the log too. The author info didn't change. What am I doing wrong here?

Update: As mentioned by @elpiekay, the -f flag made the script work.

But can anyone explain the error log itself? Why does it mention about backup ? I never made any backup before (unsure what backup is being referred in the error log)

解决方案

Actually, a better practice is to:

You can instead used right now its possible successor: newren/git-filter-repo (in Python), and its example section:

cd repo
git filter-repo --mailmap my-mailmap

with my-mailmap:

Correct Name <correct@email.com> <old@email.com>

That would replace the author name and email of any commit done by anyone with <old@email.com>

See git shortlog mapping author section for the exact syntax of

这篇关于如何使用过滤器分支更改多个提交的提交作者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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