Automates updating your old GitHub username to a new one across all your repositories.
-
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
, andpush
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.
-
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)"
andssh-add ~/.ssh/id_ed25519
-
cat ~/.ssh/id_ed25519.pub | clip
then paste to GitHub Settings. -
Test:
ssh -T git@github.com
(typeyes
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"
-
-
Clone this Repository:
git clone git@github.com:your-new-username/github-username-updater.git cd github-username-updater
-
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.
- Replace
-
Configure
main.py
:-
Edit
OLD_USERNAME
andNEW_USERNAME
at the top ofmain.py
. -
Adjust
FILE_EXTENSIONS
if needed.
-
Run the script with:
python main.py
-
Case Sensitivity: Replacement is case-sensitive. Modify
main.py
for case-insensitivity if required (uncommentimport re
and usere.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.
This project is licensed under the MIT License.