使用Git同步“Repo”存储库中的一个项目

时间:2014-03-05 18:14:06

标签: git git-repo

我公司的某些人使用Repo来管理多个存储库。我需要阅读(不要改变/提交)这些内容。

我希望避免安装Repo,只需使用Git。以下是获取我关注的存储库的说明:

repo init -u git://git-master/x/manifest.git -b dev/foo-bar -m bar.xml
repo sync

如何使用vanilla Git同步相同的信息?

1 个答案:

答案 0 :(得分:3)

git-repo使用名为manifest.xml的文件列出项目的所有git存储库。

要仅使用git访问存储库,您只需获取manifest.xml,读取存储库URL并克隆它。


首先:获取清单

$ git clone -b dev/foo-bar git://git-master/x/manifest.git
$ vi manifest/bar.xml

第二:读取存储库URL

你应该有类似的东西(查看manifest format):

<?xml version="1.0" encoding="UTF-8"?>
<manifest>

  <remote  name="origin" fetch="git://git-master/x" />

  <default revision="master" remote="origin" />

  <project name="my/first/project" />
  <project name="my/second/project" />

</manifest>

搜索要克隆的存储库(例如my/second/project),从manifest.remote.fetch属性构建克隆URL。我们在这里:

clone URL = git://git-master/x/my/second/project

注意:manifest.remote.fetch可以是绝对或相对URL。如果是亲戚,则必须先添加清单URL。


第三:克隆存储库

git clone git://git-master/x/my/second/project

注意:您可以查看manifest.default.revisionmanifest.project.revision以确保您获取了良好的分支。


然而,由于repo只是一个脚本,您可以轻松地将其安装在您的主目录中,如下所示:

$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
相关问题