Skip to content

Instantly share code, notes, and snippets.

@fipso
Last active April 18, 2022 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fipso/b02029bf209ce4e56ce31172a85a0dff to your computer and use it in GitHub Desktop.
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
#!/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