How to clone repository to a remote server/repository with Mercurial

后端 未结 3 887
说谎
说谎 2020-12-05 00:32

Found myself quite confused today about this.

I create a blank repository locally(hg init), cloned it to working copy, added some code, commited and pushed it(to loc

相关标签:
3条回答
  • 2020-12-05 00:55

    You'll want to check out the publishing repositories wiki page to get into web interfaces and access controls, but at it's most basic you can do something like this:

    hg clone yourlocalrepo ssh://you@server//home/you/repo
    

    That clones your local repo to a remote location of your choosing. Note that there are two double slashes in that URL.

    You can't create a remote repo like that using http://, only ssh://. If all you have is http to hgweb.cgi you can 'hg init' an empty repo on the server and then hg push to it.

    0 讨论(0)
  • 2020-12-05 00:57

    For those that come later and don't want to bother about the hassles of ssh for pushing changes to a server built to host repos, you can just init on the server, and then push as you do every other repo.

    # on server:
    cd repos/
    mkdir myrepo
    cd myrepo
    hg init
    cd ..
    chown -R apache:apache myrepo
    
    cd ..
    vim hgweb.config
    
    # change [paths]
    [paths]
    myrepo = /path/to/myrepo
    
    
    
    # on your machine
    
    # make sure you've configured hgrc correctly
    [paths]
    default = http://server/hg/repos/myrepo
    
    hg push
    
    # ???
    
    # profit
    
    0 讨论(0)
  • 2020-12-05 01:02

    If your "official" repositories are served up by an HTTP server, and you want to create a repo in the central location based on a local machine's repo, here's one way. You need admin rights on the central server to do this.

    e.g. I'm developing on windows, and my central repository is running on linux and served by lighttpd per the official guide. The server's central repo directory is /var/hg/repos/, owned by the user/group www-data. My local machine's IP is 10.1.10.100, and the repository I want to clone is named foo.

    1. On the local machine, open a command prompt into the repository directory and type hg serve. This runs the local hg web server, which will allow the server to pull from it.
    2. ssh into the central repo server, logging in as a user with sudo rights to www-data.
    3. cd /var/hg/repos
    4. sudo -u www-data hg clone http://10.1.10.100 foo
    0 讨论(0)
提交回复
热议问题