git为特定的提交者更改提交者姓名和电子邮件的所有历史记录 [英] git change all history for committers names and email for specific committer

查看:724
本文介绍了git为特定的提交者更改提交者姓名和电子邮件的所有历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于foreach allcommits if committer_name =Hugo Casa
更改:
committer_name
committer_email
author_name
author_email

并且在执行此操作后,
推送并刷新历史数据。



请检查helppp并发现:

  git filter-branch --commit-filter'
if [$ GIT_COMMITTER_NAME=production251];
然后
GIT_COMMITTER_NAME =Hugo Casanova;
GIT_AUTHOR_NAME =Hugo Casanova;
GIT_COMMITTER_EMAIL =hugo.casanova.ibusplus.com;
GIT_AUTHOR_EMAIL =hugo.casanova.ibusplus.com;
git commit-tree$ @;
else
git commit-tree$ @;
fi'HEAD


git filter-branch --env-filter'
oldname =(旧名称)
oldemail =(旧电子邮件)
newname =(新名称)
newemail =(新电子邮件)
[$ GIT_AUTHOR_EMAIL=$ oldemail]&& GIT_AUTHOR_EMAIL =$ newemail
[$ GIT_COMMITTER_EMAIL=$ oldemail]&& GIT_COMMITTER_EMAIL =$ newemail
[$ GIT_AUTHOR_NAME=$ oldname]&& GIT_AUTHOR_NAME =$ newname
[$ GIT_COMMITTER_NAME=$ oldname]&& GIT_COMMITTER_NAME =$ newname
'HEAD

但是...之后:
写入:git log --pretty = format:%an| sort -u
和production251 show的名字..



我发现了新的代码:



如果[$ GIT_COMMITTER_NAME= dmiguel];
然后
GIT_COMMITTER_NAME =Diana Miguel;
GIT_COMMITTER_EMAIL = paola.miguel@ibusplus.com;
GIT_AUTHOR_NAME =Diana Miguel;
GIT_AUTHOR_EMAIL =paola.miguel@ibusplus.com;
fi' - --all

这是好的还是不行?将这段代码放在终端(ubuntu)上后,需要一些代码adittional?,push或其他东西?

git commit-tree 。你可以把它全部放在同一个命令行上,或者在它们前面使用 export


How i cant change the name and email for all my commits history but for and specific commiter..

something like, foreach allcommits if committer_name = "Hugo Casa" change : committer_name committer_email author_name author_email

and after do this, push and refresh the data of the history.

please helppp i search and found this:

git filter-branch --commit-filter '
        if [ "$GIT_COMMITTER_NAME" = "production251" ];
        then
                GIT_COMMITTER_NAME="Hugo Casanova";
                GIT_AUTHOR_NAME="Hugo Casanova";
                GIT_COMMITTER_EMAIL="hugo.casanova.ibusplus.com";
                GIT_AUTHOR_EMAIL="hugo.casanova.ibusplus.com";
                git commit-tree "$@";
        else
                git commit-tree "$@";
        fi' HEAD


git filter-branch --env-filter '
    oldname="(old name)"
    oldemail="(old email)"
    newname="(new name)"
    newemail="(new email)"
    [ "$GIT_AUTHOR_EMAIL" = "$oldemail" ] && GIT_AUTHOR_EMAIL="$newemail"
    [ "$GIT_COMMITTER_EMAIL" = "$oldemail" ] && GIT_COMMITTER_EMAIL="$newemail"
    [ "$GIT_AUTHOR_NAME" = "$oldname" ] && GIT_AUTHOR_NAME="$newname"
    [ "$GIT_COMMITTER_NAME" = "$oldname" ] && GIT_COMMITTER_NAME="$newname"
    ' HEAD

but...after that : write: git log --pretty=format:"%an" | sort -u and the name of production251 show ..

i found new code:

git filter-branch --force --env-filter ' if [ "$GIT_COMMITTER_NAME" = dmiguel" ]; then GIT_COMMITTER_NAME="Diana Miguel"; GIT_COMMITTER_EMAIL="paola.miguel@ibusplus.com"; GIT_AUTHOR_NAME="Diana Miguel"; GIT_AUTHOR_EMAIL="paola.miguel@ibusplus.com"; fi' -- --all

this is well? or not? after put this code on terminal (ubuntu), need some code adittional?, push or something?

解决方案

You are losing the values you set for GIT_COMMITTER_NAME and the others between when you set them and when you execute git commit-tree. You either need to make it all on the same command line or use export in front of them.

这篇关于git为特定的提交者更改提交者姓名和电子邮件的所有历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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