Search code examples
mercurialbranchpull

How can only a specific branch be implicitly pulled in Mercurial


Running hg pull implicitly retrieves everything on the default remote repo, while hg pull -b Branch-0 explicitly pulls changes only from branch Branch-0 from default.

Is there a way to configure/script mercurial to implicitly pull only say Branch-0 from remote if a branch is not specified?

It would be great if the default branch could be specific to a remote path, but I don't find that mandatory.

i.e.

$ hg pull remote
# only commits from Branch-0 were pulled

Solution

  • You can work with alias in your .hgrc which allows to define new commands. You can use it also to re-define a built-in command like pull - yet that is explicitly warned against in the help files, so use the last line with great care or not at all:

    [alias]
    pullmybranch = pull -b MYBRANCH
    pull = pull -b MYBRANCH