How do you set the username that Mercurial uses for commit?

When I do something in Mercurial, like this:

hg commit -m "username question" 

I see this output:

 No username found, using 'WindowsVistaAdmin@ChunkyMonkey' instead 

ChunkyMonkey is my Windows machine name, and obviously, WindowsVistaAdmin is the user I signed up with, as on this computer.

How can I set a username for something more respectable or at least shorter?

+59
mercurial
Sep 09 '09 at 20:08
source share
5 answers

In the file ~/.hgrc (* nix) or mercurial.ini (Windows):

 [ui] username = First Last <email@address.com> 

( mercurial.ini is located in C:\Documents and Settings\[username]\ for XP and below, C:\Users\[username]\ for Vista and above. You can also run hgtk userconfig if TortoiseHg is installed and make it this way way.)

+92
Sep 09 '09 at 20:10
source share
— -

you can specify your username on the command line directly if you want to use --config. eg,

 hg --config ui.username=frymaster -m "comment here" commit 

in fact, you can override anything in your .hgrc with this command. just look at your .hgrc and pay attention to the format:

 [section] key=val 

which translates directly to

 hg --config section.key=val 
+20
Apr 11 '14 at
source share

Information from here :

Username Setting

When you try to run hg commit for the first time, it is not guaranteed to succeed. Mercurial records your name and address with each change you make, so that you and others will later find out who made each change. Mercurial attempts to automatically determine a reasonable username to commit the change. This will perform each of the following methods actions, in order:

  • If you specify the -u option for the hg commit command in the line command followed by the username, this is always with the highest priority.
  • If you set the HGUSER environment variable, this is verified as follows.
  • If you create a file in your home directory called .hgrc, the username that will be used is the following. To find out what the file should look like, see "Creating a Mercury Configuration File" below.
  • If you set the EMAIL environment variable, the following will be used.
  • Mercurial will ask your system to find out your local username and hostname and create a username from these components. Since this often leads to a username that is not very useful, it will print if it should.

If all these mechanisms do not work, Mercurial will fail by printing an error message. In this case, it will not allow you to commit until you configure the username.

You should think of the HGUSER environment variable and the -u option to the hg commit command as ways to uncheck the user's default Mercurial. For normal use, the simplest and most reliable way to set a username for you is to create a .hgrc file; see below for more details.

+15
Sep 09 '09 at 20:11
source share

This is what my windows /users/xxx/mercurial.ini looks like. I do not need to enter a username or passwords for anything. It looks like it could be a specific repo. I have tortoiseHG installed, not sure if it matters.

 [ui] username=mbroekhuis [auth] repo.prefix=http://myrepo repo.username=mbroekhuis repo.password=secret 
+2
Apr 23 '13 at 16:40
source share

For those trying to use an HG workstation

Settings

enter image description here

global user settings

enter image description here

Edit file

enter image description here

Save

+1
Sep 23 '16 at 7:52
source share



All Articles