How to save password in Mercurial/TortoiseHg

If you're getting started with Mercurial and TortoiseHg, you'll very soon notice that Mercurial does not store your password for you, and requires you to enter it every time you want to do anything. [adsense8]

This is great for security purposes, but it's also a huge pain in the butt. Especially if your password is a long random string of various upper and lower case characters, numbers and symbols, like any secure password should be.

Fortunately, there is a way of storing your password so TortoiseHg doesn't ask for it all the time - using the keyring extension (which comes bundled with TortoiseHg, so no need to download anything new) And it's really easy to use too!

The Solution:

  1. Open your mercurial.ini file. This should be located in your computer's profile folder (for example, my mercurial.ini file is located at C:\Users\Mikey\mercurial.ini).
  2. Activate the keyring extension by entering the following at the bottom of your mercurial.ini file: [extensions] mercurial_keyring=
  3. Associate your username with the push URL by entering the following just below that in the same file: [paths] default = https://@bitbucket.org/tortoisehg/thg
  4. Now use TortoiseHg as normal. You will need to enter your password once, but hopefully never again!


That should do it! If it doesn't work, also enter the following into your mercurial.ini file: [ui] username = <yourusername> <emailaddress>

and you should be good to go. The best thing about this solution is that it does not store your password in plaintext (a big no-no).

See http://stackoverflow.com/questions/1997601/store-password-in-tortoisehg for more detailed info, and other possible ways of storing your password.

Find me on Twitter!