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

前端 未结 5 816
夕颜
夕颜 2021-01-31 01:06

When I commit something in Mercurial like this:

hg commit -m \"username question\"

I see this output:

No username found, using          


        
5条回答
  •  鱼传尺愫
    2021-01-31 01:32

    Information from here:

    Setting up a username

    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 that you commit, so that you and others will later be able to tell who made each change. Mercurial tries to automatically figure out a sensible username to commit the change with. It will attempt each of the following methods, in order:

    1. If you specify a -u option to the hg commit command on the command line, followed by a username, this is always given the highest precedence.
    2. If you have set the HGUSER environment variable, this is checked next.
    3. If you create a file in your home directory called .hgrc, with a username entry, that will be used next. To see what the contents of this file should look like, refer to the section called “Creating a Mercurial configuration file” below.
    4. If you have set the EMAIL environment variable, this will be used next.
    5. Mercurial will query your system to find out your local user name and host name, and construct a username from these components. Since this often results in a username that is not very useful, it will print a warning if it has to do this.

    If all of these mechanisms fail, Mercurial will fail, printing an error message. In this case, it will not let you commit until you set up a username.

    You should think of the HGUSER environment variable and the -u option to the hg commit command as ways to override Mercurial's default selection of username. For normal use, the simplest and most robust way to set a username for yourself is by creating a .hgrc file; see below for details.

提交回复
热议问题