113

How can I set default remote repository for mercurial local repository?

ceth
  • 44,198
  • 62
  • 180
  • 289

1 Answers1

165

It's in the .hg/hgrc file.

[paths]
default = https://myserver/hg/repo1
default:pushurl = /home/me/mytestrepo
Jason Robinson
  • 923
  • 9
  • 11
moswald
  • 11,491
  • 7
  • 52
  • 78
  • 3
    Thanks. But may be there is any way to set it from command prompt? – ceth Sep 27 '10 at 13:33
  • 34
    @demas, yes: `echo -e "[paths]\ndefault = http://myserver/hg/repo1\ndefault-push = ../mytestrepo" >> .hg/hgrc` – tonfa Sep 27 '10 at 13:38
  • Yeah, tonfa's right on both counts. You do it by editing a file and if you don't want to pop open an editor you could do it by shell redirect. There's no 'set' command. – Ry4an Brase Sep 27 '10 at 13:56
  • The default-push line makes hg push hanging at "...repository locked by hostname:xxxx" – qed Mar 06 '14 at 14:55
  • That means that a process running on machine *hostname* connected on port *xxxx* has locked your repository. It has nothing to do with the `default-push` line. – moswald Mar 06 '14 at 15:37
  • For anyone new, Mercurial has added a new `--edit` option for the `config` command, which will open your config files in an editor. It's not as simple as `hg config set default=http://myserver/hg/repo1`, but it's a start. – moswald May 05 '14 at 15:04
  • 3
    @demas if you clone it from the original repo, it will set the path correctly--that's the only sane way to do it from the command line. – weberc2 Jan 06 '15 at 07:13
  • My .hg directory has no hgrc file. – felwithe Jul 21 '16 at 17:34
  • Just create one with the above contents. There's nothing magical about them. – moswald Jul 21 '16 at 18:10
  • 2
    `man hgrc` says that nowadays (9 years later:-) it should be `default:pushurl` instead of default-push. – Harald May 13 '19 at 12:40