Your old commits stay linked to your old username unless you take action

When you change your GitHub username, your account name updates everywhere — but your commit history does not. Every commit you made under your old username will still show that old name, even though your profile now displays the new one. This happens because commits store the author name and email at the moment they were created, and that data lives in the repository's permanent history.

You have two realistic paths forward: rewrite your commit history to show your new username (which requires force-pushing and affects everyone who has cloned the repo), or leave the old commits as they are and make sure new commits use your new username going forward. Which one makes sense depends on whether the repository is yours alone, shared with collaborators, or public.

Key Takeaways

  • Changing your GitHub username does not automatically update the author name on past commits — they keep showing your old username.
  • New commits will use whatever name and email you have set in your local Git configuration, so you can start fresh when ready by updating those settings.
  • Rewriting commit history to change old usernames requires a force push and will disrupt anyone else working from the repository.
  • The safest approach for shared repositories is to leave old commits unchanged and configure Git to use your new username for all future work.
  • You can verify what name Git will use for your next commit by running git config user.name and git config user.email in your terminal.

Set your local Git configuration to use your new username

Before you do anything else, tell Git on your computer what name to use for new commits. Open your terminal or command prompt and run these two commands, replacing the placeholder text with your actual information:

git config --global user.name "Your New Name" git config --global user.email "your.email@example.com"

The --global flag means this setting applies to every repository on your machine. If you want to use a different name for just one specific repository, navigate into that folder and run the same commands without the --global flag. After you set this, every new commit you make will show your new name.

To double-check what Git has stored, run git config user.name and git config user.email without the --global flag. Git will show you the local setting if one exists, or the global setting if it does not.

Decide whether to rewrite old commits or leave them alone

Rewriting commit history is powerful but destructive. Once you force-push the rewritten history back to GitHub, anyone else who has cloned the repository will have a conflicting version of the history on their machine. They will have to delete their local copy and clone it fresh, or manually resolve the conflict.

If you are the only person using the repository, or if it is a personal project with no active collaborators, rewriting is straightforward. If other people are actively working from this repository, rewriting will create real friction for them. In that case, the better choice is to accept that old commits show your old username and move forward with your new one.

Public repositories and open-source projects should almost never be rewritten, because you cannot control how many people have cloned them or what they have built on top of your commits.

Rewrite commit history using git-filter-repo (for solo projects)

If you own the repository and no one else is actively using it, you can rewrite the history to show your new username. The most reliable tool for this is git-filter-repo, which is a Python script maintained by the Git project itself.

First, install git-filter-repo. On macOS with Homebrew, run brew install git-filter-repo. On Windows or Linux, follow the installation instructions at github.com/newren/git-filter-repo. Once installed, navigate to your repository in the terminal and run:

git filter-repo --name-only "Old Name" --new-name "New Name"

Replace "Old Name" with the exact author name that appears in your old commits, and "New Name" with what you want it to say. Git will rewrite every commit that matches the old name. After it finishes, run git push --force-with-lease origin main (or replace main with whatever your default branch is called) to send the rewritten history to GitHub.

The --force-with-lease flag is safer than a plain --force because it will refuse to push if someone else has added commits to the remote in the meantime. If the push succeeds, the old commits on GitHub will now show your new username.

Use the GitHub web interface to change the email associated with commits

GitHub also lets you tell it that certain email addresses should be treated as belonging to your account, even if the commits show a different name. This does not change what the commits display, but it does link them to your profile.

Go to github.com, click your profile picture in the top right, select Settings, then click Emails in the left sidebar. Under "Add email address", enter any email you have used in past commits. GitHub will send you a confirmation link. Once you confirm it, any commits made with that email will be associated with your account, even if the author name does not match your current username.

This approach is useful if you want old commits to show up in your contribution graph without rewriting the repository history. The commits will still display the old author name, but they will link to your current profile when someone clicks on them.

Verify your changes are working

After you update your Git configuration, make a small test commit to confirm the new name appears. Create or edit any file in your repository, then run:

git add . git commit -m "Test commit with new username" git push

Go to your repository on GitHub and look at the commit log. The new commit should show your new username as the author. If it still shows the old name, double-check that you ran the git config commands correctly and that you are working in the right repository.

If you rewrite history using git-filter-repo, visit the repository on GitHub after the force push and scroll through the commit log. The old commits should now show your new username. If you see a mix of old and new usernames, it means some commits were made with a different email address than the one you rewrote — you can run git-filter-repo again with a different email to catch those.

Frequently Asked Questions

Will changing my GitHub username break links to my old commits?

No. GitHub redirects old profile URLs to your new username automatically, so links to your old profile and old commits will still work. The commit history itself does not break — only the author name displayed on each commit stays the same unless you rewrite it.

Can I change the author name on just one commit instead of all of them?

Yes, but it requires rewriting history. Run git rebase -i HEAD~N (where N is the number of commits back you want to go), mark the commit with reword, then use git commit --amend --author="New Name <email@example.com>" to change it. After that, force-push the result. This is more work than using git-filter-repo if you have many commits to change.

What if I use GitHub Desktop or another GUI instead of the terminal?

GitHub Desktop does not have a built-in tool to rewrite commit history. You can still update your Git configuration through the app's preferences — look for "Git" or "Accounts" settings and enter your new name and email there. For rewriting history, you will need to use the terminal and git-filter-repo, or use a different tool like GitKraken that has history-rewriting features built in.

Do I need to do this for every repository I own?

No. Once you update your global Git configuration with git config --global, every new commit you make in any repository will use your new name. You only need to rewrite history in repositories where you want old commits to show the new name, and only if you are comfortable with the disruption that rewriting causes.

Will my contribution graph show commits made under my old username?

Only if you add the old email address to your GitHub account under Settings > Emails and confirm it. Once you do, GitHub will count those commits toward your contribution graph even if the author name does not match your current username. If you rewrite the history to show your new name, the commits will count automatically.