简体   繁体   English

git更改提交者名称的所有历史记录,并更改特定提交者的电子邮件

[英]git change all history for committers names and email for specific committer

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 就像,foreach allcommits如果committer_name =“ Hugo Casa”更改: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: 请helppp我搜索并发现:

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" | 但是...之后:写:git log --pretty = format:“%an” | sort -u and the name of production251 show .. sort -u和production251的名称显示..

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 git filter-branch --force --env-filter'如果[[$ 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'--全部

this is well? 这样好吗 or not? 或不? after put this code on terminal (ubuntu), need some code adittional?, push or something? 将此代码放到终端(ubuntu)后,是否需要一些附加代码?是否需要推送?

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 . 您将失去为GIT_COMMITTER_NAME设置的值以及在设置它们和执行git commit-tree之间设置的其他值。 You either need to make it all on the same command line or use export in front of them. 您要么需要将它们全部放在同一命令行上,要么在它们前面使用export

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM