Make git extract a working copy only from a remote repository

git

As a system administrator I would like to be able to write an automated process for installation to a production server that:

  • has access to a remote git repository (say on git.mycompany.com)
  • can get a copy of one branch/label (say release_20110721_01) from the repository
  • will not create a local copy of the entire repository

In other words, have a central repository containing all the revisions, but then install to production servers the specific tag only.

Is there a way of doing this? At least with CVS a working copy of a module with a given tag can be obtained without having to pull a copy of the entire repository.

Best Answer

That is the main difference between a centralised VCS (like CVS) and a DVCS (Distributed): you always clone all the content of a repo, even though you can perform a shallow clone, as Olipro mentions.

  • In a CVCS, you can put everything, and get bacj only a subset of it.
  • In a DVCS, you consider a repo as a global and coherent set of files, that you always manipulate as a all.

Doing a shallow clone of just one branch is possible, but complicated: See "Partial clone with Git and Mercurial".

But I recommend not using Git as a release management / deployment tool: "How to shallow clone a single branch in git?".

I would rather go with git archive to zip the right branch/version you need, and then copy that to the appropriate server.