Sekhemty
Sekhemty

Reputation: 1532

Commit attribution when changing GitHub username?

I'm willing to update my GitHub username to be more consistent and recognizable with other sites and social media.

According to GitHub docs

Git commits that were associated with your GitHub-provided noreply email address won't be attributed to your new username and won't appear in your contributions graph. If your Git commits are associated with another email address you've added to your GitHub account, including the ID-based GitHub-provided noreply email address, they'll continue to be attributed to you and appear in your contributions graph after you've changed your username. For more information on setting your email address, see "Setting your commit email address."

What does exactly means? If I understand it correctly, if I change my username, my commits won't be attributed to me anymore? What is the correct meaning of "noreply email address" and "ID-based noreply email address"? How can I find if my commits were associated to one or another?

I other words, how can I check if I would lose my commit attributions before changing my username?

Please note that I work locally and that git config --list | grep email gives me user.email=<my-real-email>@gmail.com.

Upvotes: 6

Views: 2848

Answers (2)

GoodDeeds
GoodDeeds

Reputation: 8497

The other answer mostly answers the question, but there's an additional consideration. You can have your commits attributed to your new username even if you had been using GitHub's no-reply email address, depending on what the address looked like. The key paragraphs in the docs are these:

Note: If you created your GitHub account after July 18, 2017, your GitHub-provided no-reply email address is a seven-digit ID number and your username in the form of [email protected]. If you created your GitHub account prior to July 18, 2017, your GitHub-provided no-reply email address is your username in the form of [email protected]. You can get an ID-based GitHub-provided no-reply email address by selecting (or deselecting and reselecting) Keep my email address private in your email settings.

If you use your GitHub-provided noreply email address to make commits and then change your username, those commits will not be associated with your GitHub account. This does not apply if you're using the ID-based GitHub-provided noreply address. For more information, see "Changing your GitHub username."

Older no-reply addresses were username based, and so were tied to your GitHub username. If your commits used such an address, then they would continue to be attributed to the old username and would not switch over to your new username. If someone later takes the old username, those commits will get attributed to that user.

Since July 18, 2017, GitHub changed this feature by adding an ID to the no-reply address. This ID is now associated to your account, and is not tied to your username. If you had an ID-based address, changing the username still attributes all the commits from that address to you. However, if you started using GitHub's no-reply email feature before the ID based address was released, you would have continued using the old form of the address unless you explicitly reselected the option, as the note says.

To summarize, commits will continue to be attributed to your account after a username change, if:

  1. The commit used an email address associated with your GitHub account.
  2. The commit used an ID-based no-reply email address provided by GitHub.

Upvotes: 9

bk2204
bk2204

Reputation: 76409

Git requires an email address to be embedded in commits for both the author and committer fields. This value can be set in various ways, but is usually set with user.email. However, because spammers exist, some people don't want to embed a real email address in their commits, so GitHub provides a special email address under the domain noreply.github.com that you can use instead and that is automatically associated with your account. This is used if you check the specified option when performing web-based operations or if you set it explicitly in user.email.

Assuming you have used a different email address that is not the noreply email address that GitHub specified, all your contributions will remain associated with your account when you rename it. The way you'd look is to go into each repo and run git log --format=%ae to see the author email and then grep to find the noreply.github.com domain.

Upvotes: 2

Related Questions