Last active
October 23, 2015 12:31
-
-
Save G07cha/a6b7779f0e8a8c0d70a7 to your computer and use it in GitHub Desktop.
Easy script that allows to migrate all commits to new email and username, just call it with your username and email as arguments and wait until everything is finished.
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/sh | |
NAME=${1} | |
OLDEMAIL=${2} | |
EMAIL=${3} | |
curl --silent -X GET https://api.github.com/users/${NAME}/repos > repos.json | |
REPOS=$(cat ./repos.json | grep "\"html_url\": \"https://github.com/${NAME}/" | cut -d'"' -f4) | |
# Modified example https://help.github.com/articles/changing-author-info/ | |
for i in ${REPOS[@]}; do | |
echo "Overwriting $i" | |
git clone --bare "$i" | |
cd $(basename "$i") | |
git filter-branch --env-filter ' | |
if [ "$GIT_COMMITTER_EMAIL" = "$OLDEMAIL" ] | |
then | |
export GIT_COMMITTER_NAME="$NAME" | |
export GIT_COMMITTER_EMAIL="$EMAIL" | |
fi | |
if [ "$GIT_AUTHOR_EMAIL" = "$OLDEMAIL" ] | |
then | |
export GIT_AUTHOR_NAME="$NAME" | |
export GIT_AUTHOR_EMAIL="$EMAIL" | |
fi | |
' --tag-name-filter cat -- --branches --tags | |
git push --force --tags origin 'refs/heads/*' | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment