Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Git-change-author.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!
if [[ -z "$1" || "$1" == "--help" || -z "$2" ]]; then
echo ' Usage: git-change-author "Your Name" "email@address" [SHA1]'
exit 1
fi
AUTHOR="$1"
EMAIL="$2"
START_HASH="${3:---root}"
echo "On the next screen, you need to change 'pick' to 'edit' for every commit which you wish to alter."
echo ""
echo -n "Press ENTER to continue."
read
git rebase --rebase-merges -i ${START_HASH}
while [ "$?" -eq 0 ]; do
git -c user.name="${AUTHOR}" -c user.email="${EMAIL}" commit --amend --no-edit --author "${AUTHOR} <${EMAIL}>"
git rebase --continue
done
git rebase --rebase-merges --committer-date-is-author-date "${START_HASH}"
echo ""
echo ""
echo "Don't forget to run \`git push -f\` - preferably on a test branch first."