如何使 Hg/Git 成為遠程倉庫? (How to make Hg/Git a remote repo?)


問題描述

如何使 Hg/Git 成為遠程倉庫? (How to make Hg/Git a remote repo?)

I'm a beginner in DVCS (I'm from SVN world) and now that I mastered my own local repo, I would like to set up a remote computer (Amazon EC2) to hold my Web files so I can easily update the web application without FTP or some sorta things

I would like to end up using:

hg push http://hg.domain.com/webserver/hello

or git

git push myAmazon master

What do I have to configure in my remote server (installing Hg/Git) make a folder a repo using init and what should be next?


Maybe I wasn't 100% clear with the answer above, so here is a simple question

  

I want to replace FTP Upload by using Git / Hg push, how can I accomplish this?

So, let's imagine this scenario:

C:\Inetpub\wwwroot\mybrandNewWebApp is the root of a Site hosted in IIS (this is a remote computer, example: in Amazon EC2), at this directory I started up a repository using git init / hg init.

How can I configure this repository that from my own laptop I can do a push remote to "Uploading my changes"?

How can I configure this repository to be Reachable and Pushable?


Question from reading all comments?

Should I create other directory to be the repo and using upon a good push I could run a script that would actually update the website root directory?

‑‑‑‑‑

參考解法

方法 1:

For Mercurial you'll need to set up hgweb the web server that Mercurial comes with, at least in the source‑version.

The steps are (possibly incorrect order):

  1. Set up IIS on your server
  2. Download the Mercurial source, and follow a tutorial on which files to make available in the IIS application you set up
  3. Configure IIS to run python programs (Mercurial hgweb is a python cgi script)
  4. Configure hgweb for your hosting needs

There are numerous tutorials on the web, none of them 100% complete in the sense that if you follow them step by step it'll all work, but with a small amount of tinkering it will work.

Here's a couple:

  • Stack Overflow: How to setup Mercurial and hgwebdir on IIS?
  • Mercurial: Publishing Repositories with hgwebdir.cgi

Edit: My answer tells you how to set up a Mercurial web server that you can push to. Since your goal is to update the web server by pushing out your changes, there are other options:

I have the same type of setup, but what I have done is the following:

  1. I created an account online at one of the hosting companies (I use Kiln, but others will easily do)
  2. I then configured the repository I set up there to ping my web server whenever I pushed to the repository. Basically, when I push, the Kiln server will invoke a cgi‑script on my own server with some information
  3. That cgi‑script of mine that is pinged then executes a normal hg pull ‑u command in a local clone, and then a ROBOCOPY to mirror everything (except some debug files, and the .hg directory) into the main web site folder

This means that:

  1. I do not have to host my own repositories
  2. I do not need to go through the hassle of setting up my own Mercurial/Git server
  3. I do not need to handle (read: worry about) the security of that setup
  4. I still get push‑to‑update‑website functionality

方法 2:

If your run ssh on the server, you can use mercurial and git with their ssh‑protocols. 

You can even create repositories on the server that way:

 hg clone ~/myrepo ssh://user@server/hg/clone

方法 3:

You can use both Mercurial and Git for the purpose. If you push something from your computer, the tool will copy the new data to the remote server.

The problem is that the data just sits in the remote repository but you want it in a place where the Web server can see it, that is you're missing the "update" step (copy the data from repository into the Web server's file system).

To make it more clear:

  • commit moves the data from your local file system into your local repository.
  • push moves data between repositories (ignoring what's in the file system)
  • update/pull updates the file system. You have to do this on your web server.

My suggestion is to write a small script that runs hg update or git pull every hour or so. Install that script as a task in windows.

(by balexandreLasse V. KarlsenMackeAaron Digulla)

參考文件

  1. How to make Hg/Git a remote repo? (CC BY‑SA 3.0/4.0)

#repository #mercurial #Git






相關問題

開發代碼時如何使用 Internet Subversion 存儲庫? (How to use an Internet Subversion respository when developing code?)

在線庫報告的錯誤 (Online repository for reported bugs)

如何在Subversion儲存庫歷史記錄中查找文件? (How Do I Find a File in a Subversion Repository History?)

如何從 Nexus Professional 遷移到 Nexus OSS (How to migrate from Nexus Professional to Nexus OSS)

如何查看存儲庫? (How to see repositories?)

將遠程 github 存儲庫中的更改合併到本地存儲庫 (Merge changes from remote github repository to your local repository)

如何為 Xcode 項目設置 Git 存儲庫? (How to set up a Git repository for an Xcode project?)

如何簽入從不同存儲庫簽出的代碼 (How to check in code which is checked out from different repository)

如何使 Hg/Git 成為遠程倉庫? (How to make Hg/Git a remote repo?)

繼承是一種“is-a”關係;總結“界面”關係的好方法是什麼?——總結其他關係? (inheritance is an 'is-a' relationship; What is a good way to summarize the 'interface' relationship? -- Summarizing other relationships?)

存儲庫模式問題 (Repository Pattern Question)

為 Mac 和 Windows 設置 React Native 代碼庫 (setting up react native code repository for Mac & Windows)







留言討論