Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# solution from https://blog.tinned-software.net/rewrite-author-of-entire-git-repository/
git fetch origin
git reset --hard origin/master
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --prune=now
# from https://stackoverflow.com/a/11768843/544721
# Source: https://github.com/brauliobo/gitconfig/blob/master/configs/.gitconfig
# You can add this alias:
git config alias.change-commits '!'"f() { VAR=\$1; OLD=\$2; NEW=\$3; shift 3; git filter-branch --env-filter \"if [[ \\\"\$\`echo \$VAR\`\\\" = '\$OLD' ]]; then export \$VAR='\$NEW'; fi\" \$@; }; f "
To change the author name:
# git change-commits GIT_AUTHOR_NAME "old name" "new name"
# or the email for only the last 10 commits:
# git change-commits GIT_AUTHOR_EMAIL "old@email.com" "new@email.com" HEAD~10..HEAD
# Alias:
# change-commits = "!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [[ \\\"$`echo $VAR`\\\" = '$OLD' ]]; then export $VAR='$NEW'; fi\" \$@; }; f "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.