Skip to content

Automates updating your old GitHub username to a new one across all your repositories.

Notifications You must be signed in to change notification settings

SajagIN/Github-Usernamer-Updater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

GitHub Username Updater

Automates updating your old GitHub username to a new one across all your repositories.

✨ Features

  • Remote Pre-Check: Skips cloning if the old username isn't found remotely.

  • Shallow Clones: Downloads only the latest commit (--depth 1) for efficiency.

  • Automated Updates: Finds and replaces the old username in specified text files.

  • Git Operations: Handles pull, add, commit, and push automatically.

  • Checkpointing: Resumes from where it left off using checked.json.

  • Cleanup: Deletes local clones after successful processing.

  • Rate Limit Handling: Includes pauses to respect GitHub API limits.

🚀 Getting Started

Prerequisites

  • Python 3.x (pip install requests)

  • Git (git --version)

  • GitHub CLI (gh --version)

  • SSH Key Setup: Ensure your SSH key is generated, added to your SSH agent, and added to your GitHub account.

    • ssh-keygen -t ed25519 -C "your_email@example.com"

    • eval "$(ssh-agent -s)" and ssh-add ~/.ssh/id_ed25519

    • cat ~/.ssh/id_ed25519.pub | clip then paste to GitHub Settings.

    • Test: ssh -T git@github.com (type yes if prompted).

  • Git User Identity: Configure global Git user name and email.

    • git config --global user.name "Your Name"

    • git config --global user.email "your_email@example.com"

Setup

  1. Clone this Repository:

    git clone git@github.com:your-new-username/github-username-updater.git
    cd github-username-updater
    
    
  2. Generate Repo List:

    gh repo list "your-current-github-username" --json name,sshUrl --limit 500 > my_repos.json
    
    
    • Replace "your-current-github-username" with your actual current GitHub username.
  3. Configure main.py:

    • Edit OLD_USERNAME and NEW_USERNAME at the top of main.py.

    • Adjust FILE_EXTENSIONS if needed.

🏃 How to Run

Run the script with:

python main.py

⚠️ Important Notes

  • Case Sensitivity: Replacement is case-sensitive. Modify main.py for case-insensitivity if required (uncomment import re and use re.sub).

  • Branch Protection: Direct pushes may fail if branch protection rules are enabled.

  • Binary Files: Do NOT add binary file extensions to FILE_EXTENSIONS.

  • "Access is Denied" (Windows): Local folders might remain due to file locks. Delete cloned_repos manually after script completion.

  • Manual Review: Always verify changes on GitHub.

📄 License

This project is licensed under the MIT License.

About

Automates updating your old GitHub username to a new one across all your repositories.

Topics

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages