rewriteauthcommiter 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. if ! [[ "`pwd`" =~ ^/tmp/.* ]]; then
  3. echo "not in /tmp"
  4. echo "bailing out..."
  5. exit 1
  6. fi
  7. read -s -p "(1/2) Press Enter if you wanna rewrite the committer/author or else C-c"
  8. echo
  9. read -s -p "(2/2) Press Enter again if you wanna rewrite the committer/author"
  10. echo
  11. #src: https://stackoverflow.com/questions/4493936/git-could-i-change-my-name-and-surname-in-all-previous-commits
  12. #using export here to be sure! (didn't test without it!)
  13. export commiterName="newname"
  14. export commiterEmail="someemail@x.y"
  15. export authorName="$commiterName"
  16. export authorEmail="$commiterEmail"
  17. #git filter-branch --commit-filter \
  18. #'if test "$GIT_AUTHOR_NAME" == "OldAuthor Name"; then \
  19. #export GIT_AUTHOR_NAME="$authorName";\
  20. #export GIT_AUTHOR_EMAIL="$authorEmail";\
  21. #export GIT_COMMITTER_NAME="$commiterName";\
  22. #export GIT_COMMITTER_EMAIL="$commiterEmail";\
  23. #fi;\
  24. #git commit-tree "$@"'
  25. git filter-branch --commit-filter \
  26. 'export GIT_AUTHOR_EMAIL="$authorEmail";\
  27. export GIT_COMMITTER_EMAIL="$commiterEmail";\
  28. git commit-tree "$@"'
  29. #FIXME: committer name is not changed! (obviously)
  30. exit 0
  31. #what this does, example:
  32. * commit 0a187cd5e605c23d9565a23e23f32135bbefbf85
  33. Author: CEEmNSanORueEDL CECzNSiORrEaDi <CeEmNaSnOuReELDcCzEiNrSaOiRED@users.noreply.github.com>
  34. AuthorDate: Wed Jul 16 08:10:13 2014 +0200
  35. Commit: CEEmNSanORueEDL CECzNSiORrEaDi <CeEmNaSnOuReELDcCzEiNrSaOiRED@users.noreply.github.com>
  36. CommitDate: Wed Jul 16 08:10:13 2014 +0200
  37. Initial commit
  38. changed to:
  39. * commit bb928d37853a4bf39c1cec541c4eeb5f1a0d21da
  40. Author: CEEmNSanORueEDL CECzNSiORrEaDi <someemail@x.y>
  41. AuthorDate: Wed Jul 16 08:10:13 2014 +0200
  42. Commit: CEEmNSanORueEDL CECzNSiORrEaDi <someemail@x.y>
  43. CommitDate: Wed Jul 16 08:10:13 2014 +0200
  44. Initial commit
  45. #so for this reason(commit id changed!) I will not rewrite history! (6 june 2015)