Skip to content

Instantly share code, notes, and snippets.

@arfeo
Last active August 27, 2018 14:37
Show Gist options
  • Save arfeo/91ee9cf21aab8479c2cd564656d62e1c to your computer and use it in GitHub Desktop.
Save arfeo/91ee9cf21aab8479c2cd564656d62e1c to your computer and use it in GitHub Desktop.
Migrating a cloned repo to GitHub

Migrating a cloned repo to GitHub

$ cd /path/to/repo

$ git fetch --prune

$ git push --prune https://github.com/{USERNAME}/{NEW_REPO_NAME}.git +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/*

Changing the Git history of a repo

#!/bin/sh

git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
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

Then

$ git push --force --tags origin 'refs/heads/*'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment