Last active
April 18, 2022 08:56
-
-
Save fipso/b02029bf209ce4e56ce31172a85a0dff to your computer and use it in GitHub Desktop.
Little bash script to download all of your public github repos and rewrite your username and email in all commits
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
#!/bin/bash | |
GH_USERNAME=<GitHub Username> | |
mkdir -p /tmp/gh-noreply/ | |
cd /tmp/gh-noreply | |
for repo in $(curl --request GET https://api.github.com/users/$GH_USERNAME/repos | jq --raw-output '.[] .name'); do | |
git clone https://github.com/$GH_USERNAME/$repo | |
cd $repo | |
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --env-filter ' | |
OLD_EMAIL="<GitHub Old Email>" | |
CORRECT_NAME="<GitHub Username>" | |
CORRECT_EMAIL="<GitHub Email>" | |
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] | |
then | |
export GIT_COMMITTER_NAME="$CORRECT_NAME" | |
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" | |
fi | |
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] | |
then | |
export GIT_AUTHOR_NAME="$CORRECT_NAME" | |
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" | |
fi | |
' --tag-name-filter cat -- --branches --tags | |
git push --force | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment