A complete guide for migrating repositories from AWS CodeCommit to GitHub with all required configurations, security settings, and authentication.
- Prerequisites
- Pre-Migration Checklist
- GitHub Setup
- Authentication & Security
- Migration Process
- Post-Migration Configuration
- CI/CD Migration
- Team Migration
- Verification
- Troubleshooting
- Git (version 2.23 or higher)
- AWS CLI configured with appropriate credentials
- GitHub account (personal or organization)
- Terminal/Command line access
- AWS IAM permissions for CodeCommit (read access minimum)
- GitHub repository creation permissions
- Admin access to configure repository settings
# List all CodeCommit repositories
aws codecommit list-repositories --region us-east-1- Repository names and descriptions
- Branch protection rules
- Approval rules and policies
- Triggers and notifications
- IAM users and their permissions
- CI/CD pipelines (CodePipeline, CodeBuild)
- Webhook configurations
- Repository tags and metadata
- Export repository metadata
- Document custom configurations
- Save approval templates
- Export issue tracking data (if applicable)
For Organizations:
- Go to https://github.com/organizations/plan
- Choose appropriate plan (Free, Team, or Enterprise)
- Complete organization setup
- Configure organization settings
For Personal:
- Sign up at https://github.com/signup
- Verify email address
- Complete profile setup
Option A: Via Web Interface
- Navigate to https://github.com/new
- Enter repository name (match CodeCommit name or rename)
- Choose visibility (Public/Private)
- Do NOT initialize with README (we're importing)
- Click "Create repository"
Option B: Via GitHub CLI
# Install GitHub CLI
# Windows: winget install GitHub.cli
# Mac: brew install gh
# Linux: See https://github.com/cli/cli#installation
# Authenticate
gh auth login
# Create repository
gh repo create my-repo --private --source=. --remote=githubOption C: Via API
# Using curl
curl -X POST -H "Authorization: token YOUR_GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/repos \
-d '{"name":"my-repo","private":true}'Create PAT:
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click "Generate new token (classic)"
- Set expiration (90 days recommended, or custom)
- Select scopes:
repo(full control of private repositories)workflow(if using GitHub Actions)admin:org(if managing organization)delete_repo(if needed)
- Generate and save token securely
Store PAT securely:
# Windows - Use Git Credential Manager
git config --global credential.helper manager-core
# Mac - Use Keychain
git config --global credential.helper osxkeychain
# Linux - Use credential store
git config --global credential.helper storeGenerate SSH Key:
# Generate new SSH key
ssh-keygen -t ed25519 -C "your_email@example.com"
# Or for legacy systems:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Start SSH agent
eval "$(ssh-agent -s)"
# Add key to agent
ssh-add ~/.ssh/id_ed25519Add to GitHub:
- Copy public key:
cat ~/.ssh/id_ed25519.pub - Go to GitHub Settings → SSH and GPG keys
- Click "New SSH key"
- Paste key and save
Test connection:
ssh -T git@github.com- Go to Organization Settings → Developer settings → GitHub Apps
- Click "New GitHub App"
- Configure permissions and webhooks
- Install app to repositories
Option A: HTTPS with Git Credentials
# Configure AWS CLI
aws configure
# Install git-remote-codecommit (recommended)
pip install git-remote-codecommit
# Clone using codecommit://
git clone codecommit://my-repoOption B: SSH Keys
# Upload SSH public key to IAM
aws iam upload-ssh-public-key --user-name your-iam-user \
--ssh-public-key-body file://~/.ssh/codecommit_rsa.pub
# Configure SSH config
cat >> ~/.ssh/config << EOF
Host git-codecommit.*.amazonaws.com
User YOUR_SSH_KEY_ID
IdentityFile ~/.ssh/codecommit_rsa
EOFWe provide a Python script that automates the entire migration process.
# Install dependencies
pip install -r requirements.txt
# Install git-remote-codecommit for AWS authentication
pip install git-remote-codecommit
# Set environment variables
export GITHUB_TOKEN="your_github_token"
export AWS_REGION="us-east-1"python migrate_to_github.py --generate-configThis creates migration_config.json. Edit it with your settings:
{
"aws_region": "us-east-1",
"github_org": "your-org-name",
"create_private": true,
"enable_branch_protection": true,
"repositories": ["repo1", "repo2", "repo3"]
}Single Repository:
# Migrate one repository
python migrate_to_github.py --repo my-repo --github-org my-org
# Dry run first (recommended)
python migrate_to_github.py --repo my-repo --github-org my-org --dry-runMultiple Repositories:
# Using config file
python migrate_to_github.py --config migration_config.json
# Migrate all repositories
python migrate_to_github.py --migrate-all --github-org my-orgVerify Migration:
python migrate_to_github.py --verify my-repo --github-org my-org- ✓ Automatic repository creation on GitHub
- ✓ Mirror clone (preserves all branches, tags, history)
- ✓ Branch protection configuration
- ✓ Security features enablement
- ✓ Batch migration support
- ✓ Dry run mode
- ✓ Detailed logging
- ✓ Error handling and retry logic
- ✓ Migration verification
Options:
--config FILE Path to configuration JSON file
--repo NAME Single repository to migrate
--github-org ORG GitHub organization name
--github-user USER GitHub username (alternative to org)
--region REGION AWS region (default: us-east-1)
--dry-run Test without actual migration
--migrate-all Migrate all CodeCommit repositories
--generate-config Create sample config file
--verify REPO Verify migration for repositoryThe script generates:
migration.log- Detailed migration logs- Console output with progress and summary
- Migration summary report
This method preserves all branches, tags, and commit history.
# 1. Clone CodeCommit repository as mirror
git clone --mirror codecommit://my-repo my-repo-mirror
cd my-repo-mirror
# Or with HTTPS
git clone --mirror https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-repo my-repo-mirror
cd my-repo-mirror
# 2. Add GitHub as remote
git remote add github https://github.com/username/my-repo.git
# Or with SSH
git remote add github git@github.com:username/my-repo.git
# 3. Push everything to GitHub
git push --mirror github
# 4. Clean up
cd ..
rm -rf my-repo-mirror# 1. Clone from CodeCommit
git clone codecommit://my-repo
cd my-repo
# 2. Add GitHub remote
git remote add github https://github.com/username/my-repo.git
# 3. Push all branches
git push github --all
# 4. Push all tags
git push github --tagsCreate a migration script for multiple repositories:
#!/bin/bash
# migrate-repos.sh
# Configuration
CODECOMMIT_REGION="us-east-1"
GITHUB_ORG="your-org"
REPOS=("repo1" "repo2" "repo3")
for repo in "${REPOS[@]}"; do
echo "Migrating $repo..."
# Clone from CodeCommit
git clone --mirror "codecommit://$repo" "$repo-mirror"
cd "$repo-mirror"
# Create GitHub repo
gh repo create "$GITHUB_ORG/$repo" --private
# Push to GitHub
git push --mirror "https://github.com/$GITHUB_ORG/$repo.git"
cd ..
rm -rf "$repo-mirror"
echo "✓ $repo migrated successfully"
done- Go to https://github.com/new/import
- Enter CodeCommit repository URL
- Provide AWS credentials when prompted
- Configure repository settings
- Begin import
Configure via Web:
- Go to Repository Settings → Branches
- Add branch protection rule
- Configure for
mainormaster:- Require pull request reviews (1-2 reviewers)
- Require status checks to pass
- Require conversation resolution
- Require signed commits
- Include administrators
- Restrict who can push
Configure via API:
curl -X PUT \
-H "Authorization: token YOUR_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/branches/main/protection \
-d '{
"required_status_checks": {
"strict": true,
"contexts": ["ci/test"]
},
"enforce_admins": true,
"required_pull_request_reviews": {
"required_approving_review_count": 2
},
"restrictions": null
}'General Settings:
- Set repository description
- Add topics/tags
- Configure default branch
- Enable/disable features (Issues, Wiki, Projects)
- Set visibility (public/private)
Security Settings:
- Enable Dependabot alerts
- Enable Dependabot security updates
- Enable secret scanning
- Enable code scanning (CodeQL)
- Configure security policy
Collaboration Settings:
- Set up CODEOWNERS file
- Configure merge strategies
- Enable auto-merge
- Configure branch deletion
# .github/CODEOWNERS
# Default owners for everything
* @org/team-name
# Specific paths
/docs/ @org/docs-team
*.js @org/frontend-team
/api/ @org/backend-teammkdir -p .github/ISSUE_TEMPLATECreate .github/ISSUE_TEMPLATE/bug_report.md:
---
name: Bug Report
about: Create a report to help us improve
title: '[BUG] '
labels: bug
assignees: ''
---
**Describe the bug**
A clear description of the bug.
**To Reproduce**
Steps to reproduce the behavior.
**Expected behavior**
What you expected to happen.Create .github/pull_request_template.md:
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Tests pass locally
- [ ] Added new tests
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updatedDocument your CodePipeline stages:
- Source stage (CodeCommit)
- Build stage (CodeBuild)
- Test stage
- Deploy stage
Create .github/workflows/ci.yml:
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
env:
NODE_VERSION: '18'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm test
- name: Build
run: npm run build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: dist/
deploy:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Deploy to production
run: |
# Add your deployment commands
echo "Deploying to production..."In CodeBuild:
- Secrets stored in Parameter Store or Secrets Manager
In GitHub:
- Go to Repository Settings → Secrets and variables → Actions
- Add repository secrets
- Use in workflows:
${{ secrets.SECRET_NAME }}
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 sync ./dist s3://my-bucket- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Deploy to AWS
run: |
aws deploy create-deployment \
--application-name my-app \
--deployment-group my-group \
--github-location repository=${{ github.repository }},commitId=${{ github.sha }}Create a mapping document:
| AWS IAM User | GitHub Username | Role |
|---|---|---|
| john.doe | @johndoe | Admin |
| jane.smith | @janesmith | Write |
Via Web:
- Go to Repository Settings → Collaborators
- Add people or teams
- Set permissions (Read, Write, Admin)
Via CLI:
# Add collaborator
gh api repos/OWNER/REPO/collaborators/USERNAME -X PUT \
-f permission=push- Go to Organization Settings → Teams
- Create teams (e.g., Frontend, Backend, DevOps)
- Add members to teams
- Grant team access to repositories
# Grant team access
gh api orgs/ORG/teams/TEAM/repos/OWNER/REPO -X PUT \
-f permission=push# Clone from GitHub
git clone https://github.com/username/my-repo.git verify-repo
cd verify-repo
# Check all branches
git branch -a
# Check all tags
git tag -l
# Verify commit history
git log --oneline --graph --all
# Compare with CodeCommit
git remote add codecommit codecommit://my-repo
git fetch codecommit
git diff codecommit/main origin/main- All branches migrated
- All tags migrated
- Commit history intact
- File permissions preserved
- .gitignore working correctly
- LFS files migrated (if applicable)
- Branch protection rules configured
- Team access configured
- CI/CD pipeline working
- Secrets configured
- Documentation updated
# Create test branch
git checkout -b test-pipeline
# Make small change
echo "# Test" >> README.md
git add README.md
git commit -m "Test CI/CD pipeline"
# Push and create PR
git push origin test-pipeline
gh pr create --title "Test Pipeline" --body "Testing CI/CD"Problem: fatal: Authentication failed
Solutions:
# Clear credential cache
git credential-cache exit
# Re-authenticate with GitHub
gh auth login
# Verify SSH connection
ssh -T git@github.com
# Update remote URL
git remote set-url origin https://github.com/username/repo.gitProblem: remote: error: File X is 100.00 MB; this exceeds GitHub's file size limit
Solutions:
# Use Git LFS
git lfs install
git lfs track "*.psd"
git lfs track "*.zip"
git add .gitattributes
git commit -m "Configure Git LFS"
# Or remove large files from history
git filter-branch --tree-filter 'rm -f path/to/large/file' HEADProblem: ! [remote rejected] main -> main (protected branch hook declined)
Solution:
- Temporarily disable branch protection
- Push changes
- Re-enable branch protection
Problem: Not all branches/tags migrated
Solution:
# Fetch all from CodeCommit
git fetch codecommit --all
# Push specific branch
git push github codecommit/branch-name:branch-name
# Push all tags
git push github --tagsProblem: API rate limit exceeded
Solution:
- Wait for rate limit reset
- Use authenticated requests (higher limits)
- Use GitHub App for even higher limits
- GitHub Support: https://support.github.com
- GitHub Community: https://github.community
- GitHub Status: https://www.githubstatus.com
- AWS CodeCommit Docs: https://docs.aws.amazon.com/codecommit
- Use SSH keys or PATs, never passwords
- Enable 2FA on GitHub account
- Rotate access tokens regularly
- Use least privilege principle for permissions
- Enable security scanning features
- Review and audit access regularly
- Update README with new repository URL
- Update CI/CD documentation
- Update team onboarding docs
- Update deployment procedures
- Update webhook URLs
- Update CI/CD integrations
- Update monitoring/alerting
- Update documentation sites
- Update package registries
Send migration announcement:
- New repository URL
- Authentication changes
- New CI/CD process
- Updated workflows
- Support contacts
After verification period (30-90 days):
# Archive repository (recommended)
aws codecommit update-repository-description \
--repository-name my-repo \
--repository-description "ARCHIVED - Migrated to GitHub"
# Or delete repository
aws codecommit delete-repository \
--repository-name my-repo| Phase | Duration | Tasks |
|---|---|---|
| Planning | 1-2 weeks | Inventory, documentation, team prep |
| Setup | 1 week | GitHub setup, authentication config |
| Migration | 1-3 days | Repository migration, verification |
| Configuration | 1 week | Branch rules, CI/CD, team access |
| Testing | 1 week | Pipeline testing, team validation |
| Cutover | 1 day | Final sync, go-live |
| Monitoring | 2 weeks | Support team, fix issues |
| Cleanup | 1 week | Decommission old resources |
- ✓ All repositories migrated with complete history
- ✓ All team members have access
- ✓ CI/CD pipelines operational
- ✓ Branch protection rules enforced
- ✓ Security scanning enabled
- ✓ Documentation updated
- ✓ Team trained on new workflows
- ✓ Zero downtime during migration
Last Updated: November 2025