Skip to content

Instantly share code, notes, and snippets.

@noahp
Last active May 7, 2020 15:04
Show Gist options
  • Save noahp/08cfc816b59b7c3ec6a39ae60f8f58dc to your computer and use it in GitHub Desktop.
Save noahp/08cfc816b59b7c3ec6a39ae60f8f58dc to your computer and use it in GitHub Desktop.
git reset all authors
#!/usr/bin/env bash
# disable warning for using filter branch, we don't care lalala
export FILTER_BRANCH_SQUELCH_WARNING=1
# rewrite all authors to = committer.
git filter-branch --commit-filter \
'GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL" git commit-tree "$@"'
# these are good examples:
# https://git-scm.com/docs/git-filter-branch#_examples
# if you wanted to eg do a replace on certain author email:
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "<[email protected]>" ];
then
GIT_AUTHOR_EMAIL="<[email protected]>" git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment