2011-12-21 80 views
2

我从我的笔记本电脑上的服务器克隆了一个git存储库正在运行的macosx。 我有一台笔记本电脑B运行linux,我如何克隆笔记本电脑A上的git存储库?如何从一台机器的git存储库克隆到另一台机器?

我怎样才能得到从克隆的网址?

谢谢。

+0

您可以使用ssh从笔记本电脑B登录到笔记本电脑A吗?如果没有,请先打开它(最简单的方法是在Spotlight中搜索“ssh”)。 – 2011-12-21 00:21:28

回答

1

虽然你可以在Web服务器上托管回购,你可以保持简单,你可以直接共享文件并直接从目录克隆(这将是机器文件路径 - \ linuxbox \ gitshare \ myproject)。

我建议有一个“主”裸仓库克隆以简化机器之间的合并(如果需要)。

+0

+1 – fge 2011-12-21 00:26:42

0

我想这有点像

git clone file://\\\\192.168.0.33\yourpath 

会工作

1

您需要设置或者使用Git进程或ssh

既然你想在Mac克隆,

第一方式 - 使用git守护进程,轻量级服务器

  1. Mac:在Mac上头到您的存储库,确保它是裸露的,即我。e可以运行ls -lrt,它应该看起来像

    drwxr-xr-x 4 fooo admin 136 21 Dec 12:26 refs 
    -rw-r--r-- 1 fooo admin 205 21 Dec 12:26 packed-refs 
    drwxr-xr-x 4 fooo admin 136 21 Dec 12:26 objects 
    drwxr-xr-x 3 fooo admin 102 21 Dec 12:26 info 
    drwxr-xr-x 12 fooo admin 408 21 Dec 12:26 hooks 
    -rw-r--r-- 1 fooo admin 73 21 Dec 12:26 description 
    -rw-r--r-- 1 fooo admin 161 21 Dec 12:26 config 
    drwxr-xr-x 2 fooo admin 68 21 Dec 12:26 branches 
    -rw-r--r-- 1 fooo admin 23 21 Dec 12:26 HEAD 
    

    如果没有,则执行步骤2

  2. 运行git clone --bare /<Path to your repository>

  3. 创建一个空文件git的守护出口-OK: echo '' > git-daemon-export-ok

  4. 运行

    git daemon --base-path=`pwd` --verbose --port=9418 
    
  5. 的Linux:克隆你的Git仓库:

    git clone git://<mac os ip address> <name of folder you want to check out to> 
    

    例子 -

    git clone git://192.168.1.2 javaAddOn 
    

方式二 - 用SSH - [稍硬]

  1. MAC:在Mac头部系统预置=>远程登录

  2. 打开终端创建ssh密钥:

    cd ~ 
    ssh-keygen -t rsa #Press enter for all default values 
    cd .ssh 
    cat id_rsa.pub >> authorized_keys 
    
  3. LINUX:执行相同的步骤,在步骤2中,跳过创建在authorized_keys中

  4. 复制从MAC下的〜/ .ssh /授权密钥到Ubuntu的 -

    scp <macuser>@<macip>:/Users/<macuser>/.ssh/authorized_keys ~/.ssh/ 
    
  5. 检查以确保您可以从Linux的ssh。 ssh <macuser>@<macip>

  6. 如果第5步成功,您可以使用git。

    git clone <macuser>@<macip>:<Full Path of the repository location 
    

例如

git clone [email protected]:/Users/pm/repositories_git/JavaTasks 

最后,如果你想在Mac和Linux的发展和双方承诺,你必须使用第二种方法,然后推拉变化。我有完全相同的设置,但通常我只在Linux中开发,然后将更改推送到Mac。

相关问题