I started to use HgGit extension for mercurial to have copy of repository at GitHub. Almost everything is working well, but in commits information at GitHub I see invalid-email-address (author)
instead of my username. Is there a way to show username correctly in this case?
You could use any email address. But, you must have used an email address that is connected with your GitHub account. The email address linked with Github ensures that commits are attributed to you and appear in your contributions graph.
Another reason for using a real email would be if someone in the future wanted to contact you directly about a commit. While the services such as GitLab and GitHub allow for leaving comments on commits and mentioning people to ping them, it is nice to have a way that isn't tied to the service.
Git uses your email address to associate your name to any commits you author. Once you push your commits to a public repository on GitHub, the authorship metadata is published as well.
In order to fix the "invalid-email-address" issue you have to find old "git author names" in commits and set new names and email addresses of the "Author" and "Committer" for the commits before you push newly converted repository to GutHub.
This fix (search and replace...) is done using "git filter-branch" command. You may see ready to use example here: (now it's dead?!) Mercurial to Git, solving "invalid-email-address"
[Edited:] As the link above is dead now, I provide my example of the "fix-user-email.sh" file below. As yo may see, here two variants of an author name are being translated into the same valid GIT name/email pair:
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_AUTHOR_NAME" = "peter.pen" ]
then
cn="peterpen"
cm="[email protected]"
an="peterpen"
am="[email protected]"
fi
if [ "$GIT_AUTHOR_NAME" = "peterpen" ]
then
cn="peterpen"
cm="[email protected]"
an="peterpen"
am="[email protected]"
fi
export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"
'
I personally executed commands from the above mentioned page step by step in cygwin bash window (actually I ran/modified/re-ran a script in order to simplify my life, of course :-) ) and checked results using GIT-GUI...
When you are ready to test repository on GitHub,
A username in Mercurial is usually of the form:
Name <[email protected]>
Git also is usually set up with a name and an e-mail address for the user.
You probably need to specify an e-mail address in your username in your Mercurial config so that the username in the commits works correctly on github.
This username is not required to be the same as your username at any particular website, it's for commit information. If it were required to be the same, how would you ever be able to push changesets done by someone else?
For example, my bitbucket username is different than my Mercurial username on my commits, and the way I keep my bitbucket username and password out of the bitbucket paths in the repo's hgrc
is to use the [auth]
section of my user .hgrc
/Mercurial.ini
:
[auth]
bb.prefix = bitbucket.org
bb.schemes = https
bb.username = myBBusername
bb.password = myBBpassword
Putting the password here is optional (you'll be prompted), but there are more secure alternatives for storing it, such as the keyring extension.
However, it's a bit late to change the username on existing changesets (you'd have to re-write the repo's entire history).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With