git filter-branch --env-filter ' OLD_EMAIL="原来的邮箱" CORRECT_NAME="现在的名字" CORRECT_EMAIL="现在的邮箱" 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
特殊情况-如果上面的批量修改命令执行失败的话,执行一下这段命令:
bashgit filter-branch -f --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD
git清理分支提交记录
1 2 3 4 5 6 7 8 9 10 11 12
1.Checkout git checkout --orphan latest_branch 2. Add all the files git add -A 3. Commit the changes git commit -am "commit message" 4. Delete the branch git branch -D master 5.Rename the current branch to master git branch -m master 6.Finally, force update your repository git push -f origin master