2008-12-18 16 views
135

我想知道如何簡單地發佈http =很像Mercurial的hg serve!在Windows /工作盒做到這一點:Git serve:我想那麼簡單

git serve 

,然後在Linux中簡單地去:

git clone http://project project 

完成。

+0

您是否知道克隆一個SVN回購的混帳svn的克隆是棘手? http://subtlegradient.com/articles/2008/04/22/cloning-a-git-svn-clone – bendin 2008-12-18 09:06:17

+0

爲什麼不在你的linux筆記本廣告上直接安裝svn直接從項目倉庫簽出? Git可能會成爲新的熱點,但在這種特殊情況下,看起來好像讓你的生活變得不必要的複雜。 – bendin 2008-12-18 09:08:44

+0

bendin不,我不知道這是棘手的,因爲即時建立環境現在我很高興你發言... – Setori 2008-12-18 09:20:22

回答

193

導航到你的項目,並開始git的守護與以下開關:

cd project 
git daemon --reuseaddr --base-path=. --export-all --verbose 

這告訴GIT-守護進程來供應了當前目錄中的所有項目(我假設是包含項目目錄中。 git /文件夾)。它還告訴它重新使用相同的地址,如果你關閉它並啓動備份太快。

你可以把它放到一個批處理腳本中,使用一個容易記住的名稱,比如「gitserve」,所以你不需要再輸入一遍。正如一些評論建議,在最新版本的Git,你可以add an alias to the Git config

[alias] 
    serve = !git daemon --reuseaddr --verbose --base-path=. --export-all ./.git 

一旦這樣的服務器(你的Windows盒)中進行,你可以這樣做:

git serve 

git的守護使用的git://協議進行傳輸,所以在客戶端(你的Linux機器),你需要做的:

git clone git://123.456.789.111/ project 
+4

哦,你是了不起的人,謝謝 – Setori 2008-12-18 09:19:03

+3

你可以添加命令作爲別名.gitconfig文件,如下所述:http://git.or.cz/gitwiki/Aliases#Serverepoonthespot – RFelix 2009-07-07 16:08:44

14

而不是寫自己的批處理腳本,使用gitjour。它知道如何正確啓動git守護進程,並通過mDNS廣播克隆URL,因此您可以在Linux機器上執行gitjour show並複製並粘貼。

此外,還有一篇很好的文章,概述了gitjour和Nic Nic博士的其他許多類似工具,What is *jour and why they are killer apps for RailsCamp08

11

如果你只是想用網頁瀏覽器

git-instaweb

$ git instaweb -d apache2 --start 
$ lynx localhost:1234 
8

暴露庫下面是一個替代方法。你將需要安裝python。

  • 運行git update-server-info
  • 轉到.git目錄
  • 運行python -mSimpleHTTPServer

(只需創建一個在您gitconfig的別名)

現在你可以拉回購與git pull http://HOST_NAME:8000/

PS:使用時他可以設置的git守護進程解決方案--base-path=.git所以url是git://HOST/

12

當前使用兩個別名 - serve和hub。服務爲只讀共享和輪轂的讀/寫共享:

[alias] 
    serve = !git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose 
    hub = !git daemon --base-path=. --export-all --enable=receive-pack --reuseaddr --informative-errors --verbose 

此外,還有關於通過Git進程共享更詳細的教程:http://l.rw.rw/git-daemon

0

的git-Web用戶界面是一個Git擴展,它提供了基於Web的用戶界面和克隆/從其他計算機拉動能力

https://github.com/alberthier/git-webui

$ cd my_git_repo 
$ git webui 

其他人可以

$ git clone http://<ip-of-your-computer>:8000/ repoclone 

$ git pull http://<ip-of-your-computer>:8000/ 
0

添加下列行的.git /配置

[instaweb] 
       local = true 
       httpd = webrick 
       port = 4231 

然後執行

git instaweb