contrôle de la version - Comment changer le nom de l'auteur et du committer et e-mail de plusieurs commits dans Git

Mots clés : gitversion-controlgit-filter-branchgit-rewrite-historygit

meilleur 5 Réponses contrôle de la version - Comment changer le nom de l'auteur et du committer et e-mail de plusieurs commits dans Git

vote vote

99

git rebase -i -p <some HEAD before all of your bad commits> 
 git commit --amend --author "New Author Name <email@address.com>"  
git rebase --continue 
git commit --amend --author "New Author Name <email@address.com>" --no-edit && \ git rebase --continue 
 git commit --amend --author "New Author Name <email@address.com>" 
 git -c user.name="New Author Name" -c user.email=email@address.com commit --amend --reset-author 
vote vote

81

#!/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 
Proper Name <proper@email.xx> Commit Name <commit@email.xx> 
git filter-repo --mailmap git-mailmap 
vote vote

74

git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='new@email'; GIT_COMMITTER_NAME='Newname'; GIT_COMMITTER_EMAIL='new@email';" HEAD 
git filter-branch -f --env-filter "     GIT_AUTHOR_NAME='Newname'     GIT_AUTHOR_EMAIL='new@email'     GIT_COMMITTER_NAME='Newname'     GIT_COMMITTER_EMAIL='new@email'   " HEAD 
vote vote

63

git filter-branch --commit-filter '         if [ "$GIT_COMMITTER_NAME" = "<Old Name>" ];         then                 GIT_COMMITTER_NAME="<New Name>";                 GIT_AUTHOR_NAME="<New Name>";                 GIT_COMMITTER_EMAIL="<New Email>";                 GIT_AUTHOR_EMAIL="<New Email>";                 git commit-tree "$@";         else                 git commit-tree "$@";         fi' HEAD 
git filter-branch --commit-filter "         if [ "$GIT_COMMITTER_NAME" = "<Old Name>" ];         then                 GIT_COMMITTER_NAME="<New Name>";                 GIT_AUTHOR_NAME="<New Name>";                 GIT_COMMITTER_EMAIL="<New Email>";                 GIT_AUTHOR_EMAIL="<New Email>";                 git commit-tree "$@";         else                 git commit-tree "$@";         fi" HEAD 
vote vote

58

git config --global user.name "you name" git config --global user.email you@domain.com git commit --amend --reset-author 

Questions similaires