1

我有一个带有多个代理(即分布式)的 Bamboo CI 系统,每个构建都分配给下一个可用代理;另请注意,同一存储库的不同分支的多个构建可能在同一台机器上同时运行

我的构建需要从远程 git 存储库中检出代码,这就是与 git 的集成。

目前,构建会在每次构建之前克隆存储库(硬要求),并将每个分支的完整 git 存储库(即 .git 目录)保存在同一文件系统上。

由于构建不以任何方式与 git 交互(例如推送、拉取),除了检查最新的代码,我想简单地说,用 lamens 术语,下载给定 git 分支的最新版本,仅此而已。

将不胜感激任何帮助

4

4 回答 4

2

我绝不是 git 专家,但也许这个类似的 Stack Overflow 问题会帮助你指出正确的方向:

做一个“git export”(比如“svn export”)?

于 2012-03-14T13:55:29.983 回答
1

好的,这就是我的做法:

设置:

git init build_dir
cd build_dir
# repeat for all repositories
git remote add REPO_NAME GIT_REPO_URI

签出特定分支:

git fetch --all # fetch all updates
git fetch REPO_NAME # just fetch one repo
git checkout master
git reset --hard REPO_NAME/repository

偶尔运行:

git gc --aggressive
于 2012-03-14T13:54:07.613 回答
1

事实证明,Bamboo 3.4 在勾选“Shallow clone”选项时大致遵循了 Let_Me_Be 的建议(它具有更酷的功能,例如多存储库计划、签出任务和 git 子模块)

于 2012-03-26T06:51:01.450 回答
1
git clone -b branchname --depth 1 git@git.example.com:repository.git /path/to/your/repo

This will create a so called "shallow clone". It only contains the very latest commit of the named branch. Thus you will only pull the absolutely necessary bits.

To cite from the git clone man page:

--depth <depth>
    Create a shallow clone with a history truncated to the specified number
    of revisions. A shallow repository has a number of limitations (you cannot clone
    or fetch from it, nor push from nor into it), but is adequate if you are only
    interested in the recent history of a large project with a long history, and would
    want to send in fixes as patches.

Edit: AFAIK git can not "export" from a remote directory directly. But the approach above is roughly equivalent to an export from remote. If you then don't want the .git directory, just remove it. This is way easier than in the SVN world as you have exactly one, not one in every freaking directory.

于 2012-03-26T07:02:24.480 回答