Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git重写:不更改作者名称_Git - Fatal编程技术网

git重写:不更改作者名称

git重写:不更改作者名称,git,Git,我需要重写git历史记录的原因是因为我的名字是重复的,并且它在远程系统中算作两个开发人员 我的团队最近还添加了一个预接收钩子,它拒绝未知的作者姓名 我必须立即解决这个问题,所以我遵循了和其他一些指南,试图从提交中重写作者的名字 这是我现在正在使用的: #!/bin/sh git filter-branch --env-filter ' OLD_EMAIL="tomas.p@mail.com" CORRECT_NAME="Tomas Prado" CORRECT_EMAIL="tomas.p@

我需要重写git历史记录的原因是因为我的名字是重复的,并且它在远程系统中算作两个开发人员

我的团队最近还添加了一个预接收钩子,它拒绝未知的作者姓名

我必须立即解决这个问题,所以我遵循了和其他一些指南,试图从提交中重写作者的名字

这是我现在正在使用的:

#!/bin/sh

git filter-branch --env-filter '

OLD_EMAIL="tomas.p@mail.com"
CORRECT_NAME="Tomas Prado"
CORRECT_EMAIL="tomas.p@mail.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
问题

这是一个必须更改的提交

commit 355ee6adb0540d3e2eed7163dfe36087f85feb78
Author: tomasp <tomas.p@mail.com>
Date:   Wed Apr 6 13:35:25 2016 +0200

    Fix hashed
提交355ee6adb0540d3e2eed7163dfe36087f85feb78
作者:托马斯普
日期:2016年4月6日星期三13:35:25+0200
散列修复
你看,我的名字应该是“托马斯普拉多”,但它是“托马斯普”

在执行github脚本之后,它保持不变。 我不知道该怎么办。

为什么不改用
--commit filter

git filter-branch --commit-filter '
    if [ "$GIT_AUTHOR_EMAIL" = "tomas.p@mail.com" ];
    then
            GIT_AUTHOR_NAME="Tomas Prado";
            GIT_AUTHOR_EMAIL="tomas.p@mail.com";
            if [ "$GIT_COMMITTER_EMAIL" = "tomas.p@mail.com" ];
            then
                GIT_COMMITTER_NAME="Tomas Prado";
                GIT_COMMITTER_EMAIL="tomas.p@mail.com";
                git commit-tree "$@";
            else
                git commit-tree "$@";
            fi
    else
            if [ "$GIT_COMMITTER_EMAIL" = "tomas.p@mail.com" ];
            then
                GIT_COMMITTER_NAME="Tomas Prado";
                GIT_COMMITTER_EMAIL="tomas.p@mail.com";
                git commit-tree "$@";
            else
                git commit-tree "$@";
            fi
    fi' HEAD