git change all history for committers names and email for specific committer

牧云@^-^@ 提交于 2019-12-20 04:38:49

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/25939293/git-change-all-history-for-committers-names-and-email-for-specific-committer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!