I used Mercurial in a personal project, and I have been typing my username and password every time I want to push something to the server.
I tried adding the following to the .hgrc
file in my home directory, but it seems to be completely ignored.
[ui]
username = MY_USER_NAME
password = MY_PASSWORD
How to do this the right way?
You can make an auth section in your .hgrc
or Mercurial.ini
file, like so:
[auth]
bb.prefix = https://bitbucket.org/repo/path
bb.username = foo
bb.password = foo_passwd
The ‘bb’ part is an arbitrary identifier and is used to match prefix with username and password - handy for managing different username/password combos with different sites (prefix)
You can also only specify the user name, then you will just have to type your password when you push.
I would also recommend to take a look at the keyring extension. Because it stores the password in your system’s key ring instead of a plain text file, it is more secure. It is bundled with TortoiseHg on Windows, and there is currently a discussion about distributing it as a bundled extension on all platforms.