Reputation: 41
I have a Bamboo CI system with multiple agents (i.e. distributed), each build gets assigned to the next available agent; Also note that multiple builds of different branches of the same repository might run concurrently on the same machine
My build needs to checkout the code from a remote git repository and that is as far as the integration with git goes.
Currently the build clones the repository prior to each build (hard requirement) and keeps the complete git repository (i.e. .git directory) for each of the branches on the same file system.
As the build does not interact with git in any way (e.g. push, pull) other than checking out the latest code I would like to simply, in lamens terms, download the latest version of a given git branch and nothing more.
Would appreciate any assistance
Upvotes: 1
Views: 274
Reputation: 55888
git clone -b branchname --depth 1 [email protected]: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.
Upvotes: 1
Reputation: 41
It turns out that Bamboo 3.4 roughly follows Let_Me_Be's advice out of the box when ticking the 'Shallow clone' option (which has much more cool features such as multi repository plans, checkout task and git submodules)
Upvotes: 1
Reputation: 36451
OK, this is how I would do it:
Setup:
git init build_dir
cd build_dir
# repeat for all repositories
git remote add REPO_NAME GIT_REPO_URI
Checkout a specific branch:
git fetch --all # fetch all updates
git fetch REPO_NAME # just fetch one repo
git checkout master
git reset --hard REPO_NAME/repository
Once in a while run:
git gc --aggressive
Upvotes: 1
Reputation: 383
I'm by no means a git expert, but maybe this similar Stack Overflow question will help point you in the right direction:
Do a "git export" (like "svn export")?
Upvotes: 2