Repo部署多个git项目

Repo部署

项目git仓库比较多,一次修改可能涉及多个仓库,所以要应用多仓库功能,引入Repo。

背景:

  • Git环境搭配好
  • 安装Python27(必须是2.7,3.x版本暂时不支持)

1、

获取 url,本地下载并设置环境变量。(esrlabs 参考)

md %USERPROFILE%\bin

curl https://raw.githubusercontent.com/esrlabs/git-repo/stable/repo > 
%USERPROFILE%/bin/repo

curl https://raw.githubusercontent.com/esrlabs/git-repo/stable/repo.cmd > 
%USERPROFILE%/bin/repo.cmd

%USERPROFILE%\bin (基本为 C:\Users\Administrator\bin)加入到环境变量中,cmd下方可执行repo命令。Win10需要重启,环境变量方可生效。

2、添加节点

   ~/.gitconfig:

  [portable]
      windowsNoSymlinks = true

3、执行repo命令

基础是,当前目录支持repo,也就是已经执行过 repo init操作。(Win10下 要用管理员权限的cmd,否则报 repo GitError: cannot initialize work tree。)

举例:
repo init -u [email protected]:hiltonwei/manifest -b master -m def.xml

-b 指定分支
-m 指定工程映射

manifest/default.xml 采用的 https://github.com/hiltonwei

manifest/def.xml 采用的 [email protected]:hiltonwei

4、 repo --trace sync 带trace的日志

5、repo 命令略

6、其他问题:

《3》 中,如果采用def.xml中的git协议,会找不到项目地址。
YourPath\.repo\projects\atree.git\Config文件中的 url是错误的。
url = [email protected]:hiltonwei/[email protected]:HiltonWei/atree )

需要修改 repo的python文件,manifest_xml.py的 Line:95 (_resolveFetchUrl() 函数内拼接 url的函数实现)。

扫描二维码关注公众号,回复: 13480954 查看本文章
Line:95 (_resolveFetchUr()) )

    if manifestUrl.find('git@') != -1: 
      url = url#_print("find git@")
    elif manifestUrl.find(':') != manifestUrl.find('/') - 1:
      url = urllib.parse.urljoin('gopher://' + manifestUrl, url)
      url = re.sub(r'^gopher://', '', url)
    else:
      url = urllib.parse.urljoin(manifestUrl, url)

猜你喜欢

转载自blog.csdn.net/mybachelor123/article/details/121858162