How can I add remote repositories in Mercurial?

后端 未结 4 663
忘掉有多难
忘掉有多难 2021-01-30 08:05

I am working with Git repositories in the following way:

  • I have the master repository and several remotes on the different production machines.
  • I am push
4条回答
  •  独厮守ぢ
    2021-01-30 08:39

    If you're on Unix and you have Git installed, you can use this bash function to readily add a path to the remotes without a text editor:

    add-hg-path() {
        git config -f $(hg root)/.hg/hgrc --add paths.$1 $2
        awk '{$1=$1}1' $(hg root)/.hg/hgrc > /tmp/hgrc.tmp
        mv /tmp/hgrc.tmp $(hg root)/.hg/hgrc
    }
    

    Then invoke it with:

    $ add-hg-path remote1 https://path.to/remote1
    

    If someone would like to build a Powershell equivalent, I'd like to include that as well. Other potentials improvements include error checking on the parameters and factoring out the call to $(hg root).

提交回复
热议问题