Created
December 8, 2019 09:41
-
-
Save gwpl/dbf993223c8433767c81925513bef656 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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